Skip to content

Commit

Permalink
Improve code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
dziegel committed Nov 29, 2023
1 parent 4667712 commit 9474689
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 86 deletions.
58 changes: 15 additions & 43 deletions Statemachine Test/src-gen/IoArHandlerMainDeclaration.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public:
static const StatePtr kInitialState;

// State Closed
static IoArHandlerMain::Transition ClosedHandler(ImplPtr impl, Event event);
static const State kClosed;
static const Transition::ActionType kClosedToOpenByS_PNS_ArOpend_indActions[];
static const Transition kClosedToOpenByS_PNS_ArOpend_ind;
Expand All @@ -27,22 +28,24 @@ public:
static const Transition kClosedToClosedByS_PNS_ReadReq;

// State Open
static IoArHandlerMain::Transition OpenHandler(ImplPtr impl, Event event);
static const State kOpen;
static const Transition::ActionType kOpenToClosedByS_PNS_ArClosed_indActions[];
static const Transition kOpenToClosedByS_PNS_ArClosed_ind;

static const Transition::ActionType kOpenToOpenByS_PNS_WriteReqActions[];
static const Transition kOpenToOpenByS_PNS_WriteReq;
static const Transition::ActionType kOpenToOpenByS_PNS_SwitchoverRequestBackupActions[];
static const Transition kOpenToOpenByS_PNS_SwitchoverRequestBackup;
static const Transition::ActionType kOpenToOpenByS_PNS_CheckModuleDiffActions[];
static const Transition kOpenToOpenByS_PNS_CheckModuleDiff;
static const Transition::ActionType kOpenToOpenByS_PNS_SwitchoverRequestBackupActions[];
static const Transition kOpenToOpenByS_PNS_SwitchoverRequestBackup;
static const Transition::ActionType kOpenToOpenByS_PNS_SwitchoverRequestPrimaryActions[];
static const Transition kOpenToOpenByS_PNS_SwitchoverRequestPrimary;
static const Transition::ActionType kOpenToOpenByS_PNS_ReadReqActions[];
static const Transition kOpenToOpenByS_PNS_ReadReq;

// State Parameterizing
static IoArHandlerMain::Transition ParameterizingHandler(ImplPtr impl, Event event);
static const State kParameterizing;
static const Transition::ActionType kParameterizingToWaitApplicationReadyCnfByS_PNS_ParamEndIndActions[];
static const Transition kParameterizingToWaitApplicationReadyCnfByS_PNS_ParamEndInd;
Expand All @@ -51,6 +54,7 @@ public:


// State WaitApplicationReady
static IoArHandlerMain::Transition WaitApplicationReadyHandler(ImplPtr impl, Event event);
static const State kWaitApplicationReady;
static const Transition::ActionType kWaitApplicationReadyToWaitApplicationReadyCnfBySPnpbAppTimeoutActions[];
static const Transition kWaitApplicationReadyToWaitApplicationReadyCnfBySPnpbAppTimeout;
Expand All @@ -59,6 +63,7 @@ public:


// State WaitApplicationReadyCnf
static IoArHandlerMain::Transition WaitApplicationReadyCnfHandler(ImplPtr impl, Event event);
static const State kWaitApplicationReadyCnf;
static const Transition::ActionType kWaitApplicationReadyCnfToApplicationReadyByS_PNS_ApplicationReady_cnfActions[];
static const Transition kWaitApplicationReadyCnfToApplicationReadyByS_PNS_ApplicationReady_cnf;
Expand All @@ -67,10 +72,12 @@ public:
static const Transition kWaitApplicationReadyCnfToWaitApplicationReadyCnfByS_PNS_ApplicationReady_cnf;

// State ApplicationReady
static IoArHandlerMain::Transition ApplicationReadyHandler(ImplPtr impl, Event event);
static const State kApplicationReady;


// State Ready
static IoArHandlerMain::Transition ReadyHandler(ImplPtr impl, Event event);
static const State kReady;
static const Transition::ActionType kReadyToDrWaitPlugCnfByS_PNS_DynReconfPlugActions[];
static const Transition kReadyToDrWaitPlugCnfByS_PNS_DynReconfPlug;
Expand All @@ -79,24 +86,28 @@ public:


// State DynamicReconfigurationRunning
static IoArHandlerMain::Transition DynamicReconfigurationRunningHandler(ImplPtr impl, Event event);
static const State kDynamicReconfigurationRunning;

static const Transition::ActionType kDynamicReconfigurationRunningToDynamicReconfigurationRunningBySPnioAppTimeoutDynReconfActions[];
static const Transition kDynamicReconfigurationRunningToDynamicReconfigurationRunningBySPnioAppTimeoutDynReconf;

// State DrWaitPullCnf
static IoArHandlerMain::Transition DrWaitPullCnfHandler(ImplPtr impl, Event event);
static const State kDrWaitPullCnf;
static const Transition::ActionType kDrWaitPullCnfToReadyByS_PNS_PullSubmodule_cnfActions[];
static const Transition kDrWaitPullCnfToReadyByS_PNS_PullSubmodule_cnf;


// State DrWaitApplicationReadyCnfPlugSubmodule
static IoArHandlerMain::Transition DrWaitApplicationReadyCnfPlugSubmoduleHandler(ImplPtr impl, Event event);
static const State kDrWaitApplicationReadyCnfPlugSubmodule;
static const Transition::ActionType kDrWaitApplicationReadyCnfPlugSubmoduleToReadyByS_PNS_PlugApplicationReady_cnfActions[];
static const Transition kDrWaitApplicationReadyCnfPlugSubmoduleToReadyByS_PNS_PlugApplicationReady_cnf;


// State DrWaitApplicationReadyPlugSubmodule
static IoArHandlerMain::Transition DrWaitApplicationReadyPlugSubmoduleHandler(ImplPtr impl, Event event);
static const State kDrWaitApplicationReadyPlugSubmodule;
static const Transition::ActionType kDrWaitApplicationReadyPlugSubmoduleToDrWaitApplicationReadyCnfPlugSubmoduleBySPnpbAppTimeoutActions[];
static const Transition kDrWaitApplicationReadyPlugSubmoduleToDrWaitApplicationReadyCnfPlugSubmoduleBySPnpbAppTimeout;
Expand All @@ -105,57 +116,18 @@ public:


// State DrPlugPrmSequence
static IoArHandlerMain::Transition DrPlugPrmSequenceHandler(ImplPtr impl, Event event);
static const State kDrPlugPrmSequence;
static const Transition::ActionType kDrPlugPrmSequenceToDrWaitApplicationReadyPlugSubmoduleByS_PNS_PlugParamEndIndActions[];
static const Transition kDrPlugPrmSequenceToDrWaitApplicationReadyPlugSubmoduleByS_PNS_PlugParamEndInd;


// State DrWaitPlugCnf
static IoArHandlerMain::Transition DrWaitPlugCnfHandler(ImplPtr impl, Event event);
static const State kDrWaitPlugCnf;
static const Transition::ActionType kDrWaitPlugCnfToDrPlugPrmSequenceByS_PNS_PlugSubmodule_cnfActions[];
static const Transition kDrWaitPlugCnfToDrPlugPrmSequenceByS_PNS_PlugSubmodule_cnf;




// State Closed
static IoArHandlerMain::Transition ClosedHandler(ImplPtr impl, Event event);

// State Open
static IoArHandlerMain::Transition OpenHandler(ImplPtr impl, Event event);

// State Parameterizing
static IoArHandlerMain::Transition ParameterizingHandler(ImplPtr impl, Event event);

// State WaitApplicationReady
static IoArHandlerMain::Transition WaitApplicationReadyHandler(ImplPtr impl, Event event);

// State WaitApplicationReadyCnf
static IoArHandlerMain::Transition WaitApplicationReadyCnfHandler(ImplPtr impl, Event event);

// State ApplicationReady
static IoArHandlerMain::Transition ApplicationReadyHandler(ImplPtr impl, Event event);

// State Ready
static IoArHandlerMain::Transition ReadyHandler(ImplPtr impl, Event event);

// State DynamicReconfigurationRunning
static IoArHandlerMain::Transition DynamicReconfigurationRunningHandler(ImplPtr impl, Event event);

// State DrWaitPullCnf
static IoArHandlerMain::Transition DrWaitPullCnfHandler(ImplPtr impl, Event event);

// State DrWaitApplicationReadyCnfPlugSubmodule
static IoArHandlerMain::Transition DrWaitApplicationReadyCnfPlugSubmoduleHandler(ImplPtr impl, Event event);

// State DrWaitApplicationReadyPlugSubmodule
static IoArHandlerMain::Transition DrWaitApplicationReadyPlugSubmoduleHandler(ImplPtr impl, Event event);

// State DrPlugPrmSequence
static IoArHandlerMain::Transition DrPlugPrmSequenceHandler(ImplPtr impl, Event event);

// State DrWaitPlugCnf
static IoArHandlerMain::Transition DrWaitPlugCnfHandler(ImplPtr impl, Event event);


};
36 changes: 18 additions & 18 deletions Statemachine Test/src-gen/IoArHandlerMainInstance.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -208,21 +208,21 @@ IoArHandlerMain::Transition IoArHandlerMain::ClosedHandler(ImplPtr impl, Event e

switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event))
{
case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_WriteReq):
return kClosedToClosedByS_PNS_WriteReq;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ArOpend_ind):
return kClosedToOpenByS_PNS_ArOpend_ind;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestPrimary):
return kClosedToClosedByS_PNS_SwitchoverRequestPrimary;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ReadReq):
return kClosedToClosedByS_PNS_ReadReq;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestPrimary):
return kClosedToClosedByS_PNS_SwitchoverRequestPrimary;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestBackup):
return kClosedToClosedByS_PNS_SwitchoverRequestBackup;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_WriteReq):
return kClosedToClosedByS_PNS_WriteReq;

default:
return UnhandledEvent();
}
Expand All @@ -235,23 +235,23 @@ IoArHandlerMain::Transition IoArHandlerMain::OpenHandler(ImplPtr impl, Event eve

switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event))
{
case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_CheckModuleDiff):
return kOpenToOpenByS_PNS_CheckModuleDiff;
case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_WriteReq):
return kOpenToOpenByS_PNS_WriteReq;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestPrimary):
return kOpenToOpenByS_PNS_SwitchoverRequestPrimary;
case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ArClosed_ind):
return kOpenToClosedByS_PNS_ArClosed_ind;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ReadReq):
return kOpenToOpenByS_PNS_ReadReq;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestPrimary):
return kOpenToOpenByS_PNS_SwitchoverRequestPrimary;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestBackup):
return kOpenToOpenByS_PNS_SwitchoverRequestBackup;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_WriteReq):
return kOpenToOpenByS_PNS_WriteReq;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ArClosed_ind):
return kOpenToClosedByS_PNS_ArClosed_ind;
case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_CheckModuleDiff):
return kOpenToOpenByS_PNS_CheckModuleDiff;

default:
return UnhandledEvent();
Expand Down Expand Up @@ -335,12 +335,12 @@ IoArHandlerMain::Transition IoArHandlerMain::ReadyHandler(ImplPtr impl, Event ev

switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event))
{
case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_DynReconfPull):
return kReadyToDrWaitPullCnfByS_PNS_DynReconfPull;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_DynReconfPlug):
return kReadyToDrWaitPlugCnfByS_PNS_DynReconfPlug;

case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_DynReconfPull):
return kReadyToDrWaitPullCnfByS_PNS_DynReconfPull;

default:
return UnhandledEvent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<description name="Dirk Ziegelmeiers Statemachine Framework">

</description>
<feature url="features/net.ziegelmeier.statemachine.uml.gen.cpp.feature_1.0.0.202311292034.jar" id="net.ziegelmeier.statemachine.uml.gen.cpp.feature" version="1.0.0.202311292034">
<feature url="features/net.ziegelmeier.statemachine.uml.gen.cpp.feature_1.0.0.202311292048.jar" id="net.ziegelmeier.statemachine.uml.gen.cpp.feature" version="1.0.0.202311292048">
<category name="cpp_event_framework_generator"/>
</feature>
<category-def name="cpp_event_framework_generator" label="cpp_event_framework Generator"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,27 @@ class [aStatemachine.name/] : public [aStatemachine.name/]Base
public:
static const StatePtr kInitialState;

[aStatemachine.region.generateRegion()/]

[aStatemachine.region.generateHandlerPrototypes(aStatemachine)/]
[aStatemachine.region.generateRegion(aStatemachine)/]
};
[/file]
[/template]

[comment --------------------------------------------------- /]

[template private generateRegion(aRegion : Region)]
[aRegion.eContents(Vertex).generateVertex()/]
[template private generateRegion(aRegion : Region, aStatemachine : StateMachine)]
[aRegion.eContents(Vertex).generateVertex(aStatemachine)/]
[/template]

[template private generateVertex(aState : Vertex)]
[template private generateVertex(aState : Vertex, aStatemachine : StateMachine)]
[/template]

[template private generateVertex(aState : State)]
[template private generateVertex(aState : State, aStatemachine : StateMachine)]
// State [aState.name/]
static [aStatemachine.getTransitionType()/] [aState.name/]Handler(ImplPtr impl, Event event);
static const State [aState.getStateVariable()/];
[aState.getExternalTransitions().generateTransition()/]
[aState.getInternalTransitions().generateInternalTransition()/]
[aState.eContents(Region).generateRegion()/]
[aState.eContents(Region).generateRegion(aStatemachine)/]
[/template]

[template private generateTransition(aTransition : Transition)]
Expand All @@ -59,19 +58,3 @@ 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(ImplPtr impl, Event event);

[aState.eContents(Region).generateHandlerPrototypes(aStatemachine)/]
[/template]

0 comments on commit 9474689

Please sign in to comment.