| [%- USE String %] |
| [%- MACRO CLASSNAME(str) BLOCK %] |
| [%- className = String.new %] |
| [%- strList = String.new(str).lower.split("_") %] |
| [%- FOREACH str = strList %] |
| [%- token = className.append(String.new(str).capital.text()) %] |
| [%- END %] |
| [%- className %] |
| [%- END %] |
| [%- MACRO FILENAME(str) BLOCK %] |
| [%- fileName = String.new %] |
| [%- str = CLASSNAME(str) %] |
| [%- fileName = fileName.append(str.substr(0,1)).lower %] |
| [%- fileName = fileName.append(str.substr(1)) %] |
| [%- fileName %] |
| [%- END %] |
| [%- stateList = [] %] |
| [%- FOREACH StatesArray = TemplateInputVar %] |
| [%- FOREACH State = StatesArray %] |
| [%- stateList.push(State.Name) %] |
| [%- END %] |
| [%- END %] |
| [%- stateList = stateList.unique.sort %] |
| /* |
| * Copyright 2019-present Infosys Limited |
| * |
| * SPDX-License-Identifier: Apache-2.0 |
| */ |
| |
| /************************************** |
| * [% FILENAME(State.Name) %].cpp |
| * This is an auto generated file. |
| * Please do not edit this file. |
| * All edits to be made through template source file |
| * <TOP-DIR/scripts/SMCodeGen/templates/stateMachineTmpls/stateFactory.cpp.tt> |
| **************************************/ |
| |
| #include "mmeStates/stateFactory.h" |
| [%- FOREACH state = stateList%] |
| [%- IF state != "end_state" %] |
| #include "mmeStates/[% FILENAME(state) %].h" |
| [%- END %] |
| [%- END %] |
| |
| using namespace mme; |
| |
| /********************************************** |
| * Constructor |
| ***********************************************/ |
| StateFactory::StateFactory() |
| { |
| } |
| |
| /********************************************** |
| * Destructor |
| ***********************************************/ |
| StateFactory::~StateFactory() |
| { |
| } |
| |
| /********************************************** |
| * creates and returns static instance |
| ***********************************************/ |
| |
| StateFactory* StateFactory::Instance() |
| { |
| static StateFactory instance; |
| return &instance; |
| } |
| |
| void StateFactory::initialize() |
| { |
| [%- FOREACH state = stateList%] |
| [%- IF state != "end_state" %] |
| [% CLASSNAME(state) %]::Instance()->initialize(); |
| [%- END %] |
| [%- END %] |
| } |