MME2 changes - Propped commits from openmme/paging branch. Added scripts
for code gen
Change-Id: Ie55032217232214ac8544ca76ea34335205329e4
diff --git a/scripts/SMCodeGen/templates/stateMachineTmpls/stateFactory.cpp.tt b/scripts/SMCodeGen/templates/stateMachineTmpls/stateFactory.cpp.tt
new file mode 100644
index 0000000..74cb717
--- /dev/null
+++ b/scripts/SMCodeGen/templates/stateMachineTmpls/stateFactory.cpp.tt
@@ -0,0 +1,78 @@
+ [%- 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 %]
+}