MME2 changes - Propped commits from openmme/paging branch. Added scripts
for code gen
Change-Id: Ie55032217232214ac8544ca76ea34335205329e4
diff --git a/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.cpp.tt b/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.cpp.tt
new file mode 100644
index 0000000..f95a5a7
--- /dev/null
+++ b/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.cpp.tt
@@ -0,0 +1,71 @@
+ [%- DataBlock = TemplateInputVar %]
+ [%- USE String %]
+ [%- MACRO CLASSNAME(str) BLOCK %]
+ [%- className = String.new %]
+ [%- strList = String.new(str).split("_") %]
+ [%- FOREACH str = strList %]
+ [%- token = className.append(String.new(str).capital.text()) %]
+ [%- END %]
+ [%- className = className.append("Manager") %]
+ [%- 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 %]
+ [%- poolMgrClassName = CLASSNAME(DataBlock.BlockName) -%]
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+/******************************************************************************
+ * [% FILENAME(DataBlock.BlockName) %].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/ctxtManagerTmpls/blockPoolManager.cpp.tt>
+ ******************************************************************************/
+
+#include "memPoolManager.h"
+#include "contextManager/dataBlocks.h"
+#include "contextManager/[% FILENAME(DataBlock.BlockName) %].h"
+
+using namespace cmn::memPool;
+
+namespace mme
+{
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ [%poolMgrClassName%]::[%poolMgrClassName%](int numOfBlocks):poolManager_m(numOfBlocks)
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ [%poolMgrClassName%]::~[%poolMgrClassName%]()
+ {
+ }
+
+ /******************************************************************************
+ * Allocate [% DataBlock.BlockName %] data block
+ ******************************************************************************/
+ [% DataBlock.BlockName %]* [%poolMgrClassName%]::allocate[% DataBlock.BlockName %]()
+ {
+ [% DataBlock.BlockName %]* [% DataBlock.BlockName %]_p = poolManager_m.allocate();
+ return [% DataBlock.BlockName %]_p;
+ }
+
+ /******************************************************************************
+ * Deallocate a [% DataBlock.BlockName %] data block
+ ******************************************************************************/
+ void [%poolMgrClassName%]::deallocate[% DataBlock.BlockName %]([% DataBlock.BlockName %]* [% DataBlock.BlockName %]p)
+ {
+ poolManager_m.free( [% DataBlock.BlockName %]p );
+ }
+}
\ No newline at end of file
diff --git a/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.h.tt b/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.h.tt
new file mode 100644
index 0000000..5055d19
--- /dev/null
+++ b/scripts/SMCodeGen/templates/ctxtManagerTmpls/blockPoolManager.h.tt
@@ -0,0 +1,82 @@
+ [%- DataBlock = TemplateInputVar %]
+ [%- USE String %]
+ [%- MACRO CLASSNAME(str) BLOCK %]
+ [%- className = String.new %]
+ [%- strList = String.new(str).split("_") %]
+ [%- FOREACH str = strList %]
+ [%- token = className.append(String.new(str).capital.text()) %]
+ [%- END %]
+ [%- className = className.append("Manager") %]
+ [%- 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 %]
+ [%- poolMgrClassName = CLASSNAME(DataBlock.BlockName) -%]
+/*
+ * Copyright 2019-present, Infosys Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __[% poolMgrClassName %]__
+#define __[% poolMgrClassName %]__
+/******************************************************
+* [% FILENAME(DataBlock.BlockName) %].h
+ * 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/ctxtManagerTmpls/blockPoolManager.h.tt>
+ ***************************************/
+#include "memPoolManager.h"
+
+namespace mme
+{
+ class [%DataBlock.BlockName%];
+ class [%poolMgrClassName%]
+ {
+ public:
+ /****************************************
+ * [% poolMgrClassName %]
+ * constructor
+ ****************************************/
+ [%poolMgrClassName%](int numOfBlocks);
+
+ /****************************************
+ * [% poolMgrClassName %]
+ * Destructor
+ ****************************************/
+ ~[%poolMgrClassName%]();
+
+ /******************************************
+ * allocate[% DataBlock.BlockName %]
+ * allocate [% DataBlock.BlockName %] data block
+ ******************************************/
+ [% DataBlock.BlockName %]* allocate[% DataBlock.BlockName %]();
+
+ /******************************************
+ * deallocate[% DataBlock.BlockName %]
+ * deallocate a [% DataBlock.BlockName %] data block
+ ******************************************/
+ void deallocate[% DataBlock.BlockName %]([% DataBlock.BlockName %]* [% DataBlock.BlockName %]p );
+
+ private:
+ cmn::memPool::MemPoolManager<[% DataBlock.BlockName %]> poolManager_m;
+ };
+};
+
+#endif
+
+
\ No newline at end of file
diff --git a/scripts/SMCodeGen/templates/ctxtManagerTmpls/dataBlocks.cpp.tt b/scripts/SMCodeGen/templates/ctxtManagerTmpls/dataBlocks.cpp.tt
new file mode 100644
index 0000000..18a1626
--- /dev/null
+++ b/scripts/SMCodeGen/templates/ctxtManagerTmpls/dataBlocks.cpp.tt
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+ [%- DataStore = templateIn %]
+ [%- USE String %]
+ [%- MACRO CLASSNAME(str) BLOCK %]
+ [%- className = String.new %]
+ [%- strList = String.new(str).split("_") %]
+ [%- FOREACH str = strList %]
+ [%- token = className.append(String.new(str).capital.text()) %]
+ [%- END %]
+ [%- className %]
+ [%- END %]
+ [%- MACRO REF(str) BLOCK %]
+ [%- primTypeList = [ "int", "short", "uint8_t", "uint16_t", "uint32_t", "unsigned int", "unsigned char", "unsigned short", "bool" ] %]
+ [%- reference = String.new %]
+ [%- reference = '&' %]
+ [%- FOREACH type = primTypeList %]
+ [%- IF str == type %]
+ [%- reference = '' %]
+ [%- END %]
+ [%- END %]
+ [%- reference %]
+ [%- END %]
+/**************************************
+ *
+ * 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/ctxtManagerTmpls/dataBlocks.cpp.tt>
+ ***************************************/
+#include "mmeBlocks/dataBlocks.h"
+
+namespace mme
+{
+ [%- FOREACH DataGroup = DataStore.DataGroups %]
+ [%- FOREACH DataBlock = DataGroup.DataBlocks %]
+ [%- dataBlockClassName = CLASSNAME(DataBlock.BlockName) %]
+ /******************************************************************************
+ *******************************************************************************
+ * [% dataBlockClassName %]
+ *******************************************************************************
+ ******************************************************************************/
+
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ [% dataBlockClassName %]::[% dataBlockClassName %]()
+ {
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ [% dataBlockClassName %]::~[% dataBlockClassName %]()
+ {
+ }
+
+ [%- FOREACH Data = DataBlock.Data %]
+ /******************************************************************************
+ * sets [% Data.Name %]
+ ******************************************************************************/
+ void [% dataBlockClassName %]::set[% Data.Name %]( const [% Data.Type %][% REF(Data.Type) %] [% Data.Name %]_i )
+ {
+ [% Data.Name %]_m = [% Data.Name %]_i;
+ }
+
+ /******************************************************************************
+ * returns [% Data.Name %]
+ ******************************************************************************/
+ const [% Data.Type %][% REF(Data.Type) %] [% dataBlockClassName %]::get[% Data.Name %]()const
+ {
+ return [% Data.Name %]_m;
+ }
+ [%- END %]
+
+ [%- FOREACH Child = DataBlock.Children %]
+ /******************************************************************************
+ * sets [% Child %]
+ ******************************************************************************/
+ void [% dataBlockClassName %]::set[% Child %]( [% Child %]* [% Child %]p )
+ {
+ [% Child %]_mp = [% Child %]p;
+ }
+
+ /******************************************************************************
+ * returns [% Child %]
+ ******************************************************************************/
+ [% Child %]* [% dataBlockClassName %]::get[% Child %]()
+ {
+ return [% Child %]_mp;
+ }
+[%- END %]
+[%- END %]
+[%- END %]
+} // mme
\ No newline at end of file
diff --git a/scripts/SMCodeGen/templates/ctxtManagerTmpls/dataBlocks.h.tt b/scripts/SMCodeGen/templates/ctxtManagerTmpls/dataBlocks.h.tt
new file mode 100644
index 0000000..51a189d
--- /dev/null
+++ b/scripts/SMCodeGen/templates/ctxtManagerTmpls/dataBlocks.h.tt
@@ -0,0 +1,121 @@
+ [%- DataStore = templateIn %]
+ [%- USE String %]
+ [%- MACRO CLASSNAME(str) BLOCK %]
+ [%- className = String.new %]
+ [%- strList = String.new(str).split("_") %]
+ [%- FOREACH str = strList %]
+ [%- token = className.append(String.new(str).capital.text()) %]
+ [%- END %]
+ [%- className %]
+ [%- END %]
+ [%- MACRO REF(str) BLOCK %]
+ [%- primTypeList = [ "int", "short", "uint8_t", "uint16_t", "uint32_t", "unsigned int", "unsigned char", "unsigned short", "bool" ] %]
+ [%- reference = String.new %]
+ [%- reference = '&' %]
+ [%- FOREACH type = primTypeList %]
+ [%- IF str == type %]
+ [%- reference = '' %]
+ [%- END %]
+ [%- END %]
+ [%- reference %]
+ [%- END %]
+ /*
+ * Copyright 2019-present, Infosys Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef DGM_BLOCKSTRUCTURES_H
+#define DGM_BLOCKSTRUCTURES_H
+/**************************************
+ *
+ * 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/ctxtManagerTmpls/dataBlocks.h.tt>
+ ***************************************/
+#include "permDataBlock.h"
+#include "tempDataBlock.h"
+#include "structs.h"
+
+namespace mme
+{
+ [%- FOREACH DataGroup = DataStore.DataGroups %]
+ [%- FOREACH DataBlock = DataGroup.DataBlocks %]
+ [%- dataBlockClassName = CLASSNAME(DataBlock.BlockName) %]
+ class [% dataBlockClassName %];
+ [%- END %]
+ [%- END %]
+
+ [%- FOREACH DataGroup = DataStore.DataGroups %]
+ [%- FOREACH DataBlock = DataGroup.DataBlocks %]
+ [%- dataBlockClassName = CLASSNAME(DataBlock.BlockName) %]
+ class [% dataBlockClassName %]:public SM::[% IF DataBlock.BlockType == 'Permanent' %]PermDataBlock[% ELSE %]TempDataBlock[%- END %]
+ {
+ public:
+
+ /****************************************
+ * [% dataBlockClassName %]
+ * constructor
+ ****************************************/
+ [% dataBlockClassName %]();
+
+ /****************************************
+ * ~[% dataBlockClassName %]
+ * destructor
+ ****************************************/
+ ~[% dataBlockClassName %]();
+
+ [%- FOREACH Data = DataBlock.Data %]
+ /****************************************
+ * set[% Data.Name %]
+ * set [% Data.Name %] to [% dataBlockClassName %]
+ ****************************************/
+ void set[% Data.Name %]( const [% Data.Type %][% REF(Data.Type) %] [% Data.Name %]_i );
+
+ /****************************************
+ * get[% Data.Name %]
+ * get [% Data.Name %] from [% dataBlockClassName %]
+ ****************************************/
+ const [% Data.Type %][% REF(Data.Type) %] get[% Data.Name %]()const;
+ [% END %]
+
+ [%- FOREACH Child = DataBlock.Children %]
+ /****************************************
+ * set[% Child %]
+ * set [% Child %] to [% dataBlockClassName %]
+ ****************************************/
+ void set[% Child %]( [% Child %]* [% Child %]p ) ;
+
+ /****************************************
+ * get[% Child %]
+ * get [% Child %] to [% dataBlockClassName %]
+ ****************************************/
+ [% Child %]* get[% Child %]();
+ [% END %]
+
+ private:
+
+ [%- FOREACH Data = DataBlock.Data %]
+ [%- DataName = CLASSNAME(Data.Name) %]
+ // DataName
+ [% Data.Type %] [% Data.Name %]_m;
+ [% END %]
+
+ [%- FOREACH Child = DataBlock.Children %]
+ // [% Child %]
+ [% Child %]* [% Child %]_mp;
+ [% END %]
+ };
+ [% END %]
+ [% END %]
+} // mme
+#endif
\ No newline at end of file
diff --git a/scripts/SMCodeGen/templates/ctxtManagerTmpls/subsDataGroupManager.cpp.tt b/scripts/SMCodeGen/templates/ctxtManagerTmpls/subsDataGroupManager.cpp.tt
new file mode 100644
index 0000000..44b5a2f
--- /dev/null
+++ b/scripts/SMCodeGen/templates/ctxtManagerTmpls/subsDataGroupManager.cpp.tt
@@ -0,0 +1,135 @@
+[%- DataGroup = TemplateInputVar %]
+[%- USE String %]
+[%- MACRO CLASSNAME(str) BLOCK %]
+[%- className = String.new %]
+[%- strList = String.new(str).split("_") %]
+[%- FOREACH str = strList %]
+[%- token = className.append(String.new(str).capital.text()) %]
+[%- END %]
+[%- className = className.append( "Manager" ) %]
+[%- className %]
+[%- END -%]
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**************************************
+ *
+ * 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/ctxtManagerTmpls/subsDataGroupManager.cpp.tt>
+ ***************************************/
+#include "contextManager/subsDataGroupManager.h"
+#include "log.h"
+#include "mmeStates/defaultMmeState.h"
+#include <sstream>
+
+namespace mme
+{
+ /******************************************************************************
+ * Constructor
+ ******************************************************************************/
+ SubsDataGroupManager::SubsDataGroupManager()
+ {
+ [%- FOREACH DataBlock = DataGroup.DataBlocks %]
+ [% CLASSNAME(DataBlock.BlockName) %]m_p = NULL;
+ [%- END %]
+
+ initialize();
+ }
+
+ /******************************************************************************
+ * Destructor
+ ******************************************************************************/
+ SubsDataGroupManager::~SubsDataGroupManager()
+ {
+ [%- FOREACH DataBlock = DataGroup.DataBlocks %]
+ delete [% CLASSNAME(DataBlock.BlockName) %]m_p;
+ [%- END %]
+ }
+
+ /******************************************
+ * Initializes control block and pool managers
+ ******************************************/
+ void SubsDataGroupManager::initialize()
+ {
+ initializeCBStore([% DataGroup.PoolSize %]);
+
+ [%- FOREACH DataBlock = DataGroup.DataBlocks %]
+ [% CLASSNAME(DataBlock.BlockName) %]m_p = new [% CLASSNAME(DataBlock.BlockName) %]([% DataBlock.PoolSize %]);
+ [%- END %]
+ }
+
+ /******************************************************************************
+ * creates and returns static instance
+ ******************************************************************************/
+ SubsDataGroupManager* SubsDataGroupManager::Instance()
+ {
+ static SubsDataGroupManager subDataGroupMgr;
+ return &subDataGroupMgr;
+ }
+
+ [%- FOREACH DataBlock = DataGroup.DataBlocks %]
+ [% DataBlock.BlockName %]* SubsDataGroupManager::get[% DataBlock.BlockName %]()
+ {
+ return [% CLASSNAME(DataBlock.BlockName) %]m_p->allocate[% DataBlock.BlockName %]();
+ }
+
+ void SubsDataGroupManager::delete[% DataBlock.BlockName %]([% DataBlock.BlockName %]* [% DataBlock.BlockName %]p )
+ {
+ [% CLASSNAME(DataBlock.BlockName) %]m_p->deallocate[% DataBlock.BlockName %]( [% DataBlock.BlockName %]p );
+ }
+ [%- END %]
+
+ [%- FOREACH DataBlock = DataGroup.DataBlocks %]
+ [%- FOREACH Data = DataBlock.Data %]
+ [%- IF Data.Key == 'Yes' %]
+ /******************************************
+ * Add a [% Data.Name %] as key and cb index as value to [% Data.Name %]_cb_id_map
+ ******************************************/
+ int SubsDataGroupManager::add[% Data.Name %]key( [% Data.Type %] key, int cb_index )
+ {
+ std::lock_guard<std::mutex> lock([% Data.Name %]_cb_id_map_mutex);
+
+ int rc = 1;
+
+ auto itr = [% Data.Name %]_cb_id_map.insert(std::pair<[% Data.Type %], int>( key, cb_index ));
+ if(itr.second == false)
+ {
+ rc = -1;
+ }
+ return rc;
+ }
+
+ /******************************************
+ * Delete a [% Data.Name %] key from [% Data.Name %]_cb_id_map
+ ******************************************/
+ int SubsDataGroupManager::delete[% Data.Name %]key( [% Data.Type %] key )
+ {
+ std::lock_guard<std::mutex> lock([% Data.Name %]_cb_id_map_mutex);
+
+ return [% Data.Name %]_cb_id_map.erase( key );
+ }
+
+ /******************************************
+ * Find cb with given [% Data.Name %] from [% Data.Name %]_cb_id_map
+ * returns -1 if not found, else cb index
+ ******************************************/
+ int SubsDataGroupManager::findCBWith[% Data.Name %]( [% Data.Type %] key )
+ {
+ std::lock_guard<std::mutex> lock([% Data.Name %]_cb_id_map_mutex);
+
+ auto itr = [% Data.Name %]_cb_id_map.find( key );
+ if( itr != [% Data.Name %]_cb_id_map.end())
+ {
+ return itr->second;
+ }
+ return -1;
+ }
+ [%- END %]
+ [%- END %]
+[%- END %]
+}
\ No newline at end of file
diff --git a/scripts/SMCodeGen/templates/ctxtManagerTmpls/subsDataGroupManager.h.tt b/scripts/SMCodeGen/templates/ctxtManagerTmpls/subsDataGroupManager.h.tt
new file mode 100644
index 0000000..dc34dec
--- /dev/null
+++ b/scripts/SMCodeGen/templates/ctxtManagerTmpls/subsDataGroupManager.h.tt
@@ -0,0 +1,148 @@
+ [%- DataGroup = TemplateInputVar %]
+ [%- USE String %]
+ [%- MACRO CLASSNAME(str) BLOCK %]
+ [%- className = String.new %]
+ [%- strList = String.new(str).split("_") %]
+ [%- FOREACH str = strList %]
+ [%- token = className.append(String.new(str).capital.text()) %]
+ [%- END %]
+ [%- className = className.append( "Manager" ) %]
+ [%- 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 -%]
+/*
+ * Copyright 2019-present, Infosys Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SUBS_DATAGROUPMANAGER__
+#define __SUBS_DATAGROUPMANAGER__
+/**************************************
+ *
+ * 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/ctxtManagerTmpls/subsDataGroupManager.h.tt>
+ ***************************************/
+#include <map>
+#include "dataGroupManager.h"
+#include "contextManager/dataBlocks.h"
+[%- IF DataGroup.DgName == 'SubscriberData' %]
+[%- FOREACH DataBlock = DataGroup.DataBlocks %]
+#include "contextManager/[% FILENAME(DataBlock.BlockName) %].h"
+[%- END %]
+namespace mme
+{
+ class SubsDataGroupManager:public cmn::DGM::DataGroupManager
+ {
+ public:
+
+ /******************************************
+ * Instance
+ * Creates static instance for the SubsDataGroupManager
+ *******************************************/
+ static SubsDataGroupManager* Instance();
+
+ /****************************************
+ * SubsDataGroupManager
+ * Destructor
+ ****************************************/
+ virtual ~SubsDataGroupManager();
+
+ /******************************************
+ * initialize
+ * Initializes control block and pool managers
+ ******************************************/
+ void initialize();
+
+ [%- FOREACH DataBlock = DataGroup.DataBlocks %]
+ /******************************************
+ * get[% DataBlock.BlockName %]
+ * Get [% DataBlock.BlockName %] data block
+ ******************************************/
+ [% DataBlock.BlockName %]* get[% DataBlock.BlockName %]();
+
+ /******************************************
+ * delete[% DataBlock.BlockName %]
+ * Delete a [% DataBlock.BlockName %] data block
+ ******************************************/
+ void delete[% DataBlock.BlockName %]([% DataBlock.BlockName %]* [% DataBlock.BlockName %]p );
+ [%- END %]
+
+ [%- FOREACH DataBlock = DataGroup.DataBlocks %]
+ [%- FOREACH Data = DataBlock.Data %]
+ [%- IF Data.Key == 'Yes' %]
+ /******************************************
+ * add[% Data.Name %]key
+ * Add a [% Data.Name %] as key and cb index as value to [% Data.Name %]_cb_id_map
+ ******************************************/
+ int add[% Data.Name %]key( [% Data.Type %] key, int cb_index );
+
+ /******************************************
+ * delete[% Data.Name %]key
+ * delete a [% Data.Name %] key from [% Data.Name %]_cb_id_map
+ ******************************************/
+ int delete[% Data.Name %]key( [% Data.Type %] key );
+
+ /******************************************
+ * findCBWith[% Data.Name %]
+ * Find cb with given [% Data.Name %] from [% Data.Name %]_cb_id_map
+ ******************************************/
+ int findCBWith[% Data.Name %]( [% Data.Type %] key );
+ [%- END %]
+ [%- END %]
+ [%- END %]
+
+
+ private:
+
+ /****************************************
+ * SubsDataGroupManager
+ * Private constructor
+ ****************************************/
+ SubsDataGroupManager();
+
+ [%- FOREACH DataBlock = DataGroup.DataBlocks %]
+ /****************************************
+ * [% DataBlock.BlockName %] Pool Manager
+ ****************************************/
+ [% CLASSNAME(DataBlock.BlockName) %]* [% CLASSNAME(DataBlock.BlockName) %]m_p;
+
+ [%- END %]
+
+ [%- FOREACH DataBlock = DataGroup.DataBlocks %]
+ [%- FOREACH Data = DataBlock.Data %]
+ [%- IF Data.Key == 'Yes' %]
+ /****************************************
+ * [% Data.Name %] Key Map
+ ****************************************/
+ std::map<[% Data.Type %],int> [% Data.Name %]_cb_id_map;
+
+ /****************************************
+ * [% Data.Name %] Key Map
+ ****************************************/
+ std::mutex [% Data.Name %]_cb_id_map_mutex;
+ [%- END %]
+ [%- END %]
+ [%- END %]
+ };
+};
+[% END %]
+
+#endif
\ No newline at end of file
diff --git a/scripts/SMCodeGen/templates/stateMachineTmpls/actionHandlers.cpp.tt b/scripts/SMCodeGen/templates/stateMachineTmpls/actionHandlers.cpp.tt
new file mode 100644
index 0000000..e4a98e2
--- /dev/null
+++ b/scripts/SMCodeGen/templates/stateMachineTmpls/actionHandlers.cpp.tt
@@ -0,0 +1,48 @@
+[%- BLOCK %]
+[%- actionList = [] %]
+[%- PYTHON %]
+procedure = [% TemplateInputVar %]
+actionNames = []
+import utils
+for state in procedure['States']:
+ for event in state['Events']:
+ for action in event['Actions']:
+ rc = utils.searchWordInDir(utils.outputDir, action.lower())
+ if rc is False:
+ actionNames.append(action.lower())
+flag = utils.isFileEmpty(utils.outputDir, utils.outputFileName)
+stash.set('actionList', actionNames)
+stash.set('includeHeader', flag)
+[%- END %]
+[%- END %]
+[%- IF includeHeader == 1 -%]
+/*
+ * Copyright 2019-present Infosys Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/******************************************************************************
+ *
+ * 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/actionHandlers.cpp.tt>
+ ******************************************************************************/
+#include "actionHandlers/actionHandlers.h"
+#include "controlBlock.h"
+
+using namespace mme;
+using namespace SM;
+
+[% END %]
+[%- FOREACH action = actionList -%]
+/***************************************
+* Action handler : [% action %]
+***************************************/
+ActStatus ActionHandlers::[% action %](ControlBlock& cb)
+{
+ return ActStatus::PROCEED;
+}
+
+[% END -%]
diff --git a/scripts/SMCodeGen/templates/stateMachineTmpls/actionHandlers.h.tt b/scripts/SMCodeGen/templates/stateMachineTmpls/actionHandlers.h.tt
new file mode 100644
index 0000000..66fc613
--- /dev/null
+++ b/scripts/SMCodeGen/templates/stateMachineTmpls/actionHandlers.h.tt
@@ -0,0 +1,66 @@
+[%- actions = [] %]
+[%- FOREACH actionList = TemplateInputVar%]
+ [%- FOREACH actionObj = actionList%]
+ [%- actions.push(actionObj) %]
+ [%- END %]
+[%- END %]
+[%- actions = actions.unique.sort %]
+[%- USE String %]
+/*
+ * Copyright 2019-present, Infosys Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**************************************
+ *
+ * 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/actionHandlers.h.tt>
+ **************************************/
+#ifndef ACTIONHANDLERS_H_
+#define ACTIONHANDLERS_H_
+
+#include "smTypes.h"
+
+namespace mme
+{
+ class ActionHandlers
+ {
+
+ /***************************************
+ * Constructor
+ ****************************************/
+ ActionHandlers()
+ {
+ }
+
+ /***************************************
+ * Destructor
+ ****************************************/
+ ~ActionHandlers()
+ {
+ }
+
+ public:
+ [%- FOREACH action = actions %]
+
+ /**********************************************
+ * Action handler : [%String.new(action).lower%]
+ ***********************************************/
+ static SM::ActStatus [%String.new(action).lower%](SM::ControlBlock& cb);
+ [%-END%]
+ };//ActionHandlers
+};//mme
+
+#endif /* ACTIONHANDLERS_H_ */
\ No newline at end of file
diff --git a/scripts/SMCodeGen/templates/stateMachineTmpls/enum.tt b/scripts/SMCodeGen/templates/stateMachineTmpls/enum.tt
new file mode 100644
index 0000000..dd6c455
--- /dev/null
+++ b/scripts/SMCodeGen/templates/stateMachineTmpls/enum.tt
@@ -0,0 +1,85 @@
+[%- stateList = [] %]
+[%- eventList = [] %]
+[%- actionList = [] %]
+[%- FOREACH ProcedureList = TemplateInputVar %]
+ [%- FOREACH Procedure = ProcedureList %]
+ [%- FOREACH State = Procedure.States %]
+ [%- stateList.push(State.Name) %]
+ [%- FOREACH Event = State.Events %]
+ [%- eventList.push(Event.Name) %]
+ [%- actionList = actionList.merge(Event.Actions) %]
+ [%- END %]
+ [%- END %]
+ [%- END %]
+[%- END %]
+[%- stateList = stateList.unique.sort %]
+[%- eventList = eventList.unique.sort %]
+[%- actionList = actionList.unique.sort -%]
+/*
+ * Copyright 2019-present, Infosys Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SM_ENUMS_H
+#define SM_ENUMS_H
+/**************************************
+ *
+ * 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/enum.tt>
+ **************************************/
+
+enum State_e
+{
+ [%- FOREACH state = stateList%]
+ [% state %],[% END %]
+ END_STATE
+};
+
+static constexpr const char* States[] =
+{
+ [%- FOREACH state = stateList%]
+ "[% state %]",[%END%]
+ "END_STATE"
+};
+
+enum Event_e
+{
+ [%- FOREACH event = eventList%]
+ [% event %],[%END%]
+ END_EVENT
+};
+
+static constexpr const char* Events[] =
+{
+ [%- FOREACH event = eventList%]
+ "[% event %]",[%END%]
+ "END_EVENT"
+};
+
+enum Action_e
+{
+ [%- FOREACH actions = actionList%]
+ [% actions %],[% END %]
+ END_ACTION
+};
+
+static constexpr const char* Actions[] =
+{
+ [%- FOREACH action = actionList%]
+ "[% action %]",[%END%]
+ "END_ACTION"
+};
+
+#endif
\ No newline at end of file
diff --git a/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt b/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt
new file mode 100644
index 0000000..94e0425
--- /dev/null
+++ b/scripts/SMCodeGen/templates/stateMachineTmpls/state.cpp.tt
@@ -0,0 +1,87 @@
+ [%- State = TemplateInputVar %]
+ [%- 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 %]
+ [%- stateClassName = CLASSNAME(State.Name) %]
+/*
+ * 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/state.cpp.tt>
+ **************************************/
+
+#include "smEnumTypes.h"
+#include "actionTable.h"
+#include "actionHandlers/actionHandlers.h"
+
+#include "mmeStates/[% FILENAME(State.Name) %].h"
+[%- FOREACH Event = State.Events %]
+[%- IF Event.NextState != "end_state" %]
+#include "mmeStates/[% FILENAME(Event.NextState) %].h"
+[%- END %]
+[%- END %]
+
+using namespace mme;
+using namespace SM;
+
+/******************************************************************************
+* Constructor
+******************************************************************************/
+[% stateClassName %]::[% stateClassName %]():State(State_e::[% State.Name %])
+{
+}
+
+/******************************************************************************
+* Destructor
+******************************************************************************/
+[% stateClassName %]::~[% stateClassName %]()
+{
+}
+
+/******************************************************************************
+* creates and returns static instance
+******************************************************************************/
+[% stateClassName %]* [% stateClassName %]::Instance()
+{
+ static [% stateClassName %] state;
+ return &state;
+}
+
+/******************************************************************************
+* initializes eventToActionsMap
+******************************************************************************/
+void [% stateClassName %]::initialize()
+{
+ [%- FOREACH Event = State.Events %]
+ {
+ ActionTable actionTable;
+ [%- FOREACH Action = Event.Actions %]
+ actionTable.addAction(&ActionHandlers::[% String.new(Action).lower %]);
+ [%- END %]
+ [%- IF Event.NextState != "end_state" %]
+ actionTable.setNextState([% CLASSNAME(Event.NextState) %]::Instance());
+ [%- END %]
+ eventToActionsMap.insert(pair<Event_e, ActionTable>(Event_e::[% Event.Name %], actionTable));
+ }
+ [%- END %]
+}
diff --git a/scripts/SMCodeGen/templates/stateMachineTmpls/state.h.tt b/scripts/SMCodeGen/templates/stateMachineTmpls/state.h.tt
new file mode 100644
index 0000000..36feeec
--- /dev/null
+++ b/scripts/SMCodeGen/templates/stateMachineTmpls/state.h.tt
@@ -0,0 +1,79 @@
+ [%- State = TemplateInputVar %]
+ [%- 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 %]
+ [%- stateClassName = CLASSNAME(State.Name) -%]
+/*
+ * Copyright 2019-present, Infosys Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ /******************************************************
+ * [% FILENAME(State.Name) %].h
+ * 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/state.h.tt>
+ ******************************************************/
+
+#ifndef __[% stateClassName %]__
+#define __[% stateClassName %]__
+
+#include "state.h"
+
+namespace mme {
+
+ class [% stateClassName %] : public SM::State
+ {
+ public:
+ /******************************************
+ * Instance
+ * Creates static instance for the state
+ *******************************************/
+ static [% stateClassName %]* Instance();
+
+ /****************************************
+ * [% stateClassName %]
+ * Destructor
+ ****************************************/
+ ~[% stateClassName %]();
+
+ /******************************************
+ * initialize
+ * Initializes action handlers for the state
+ * and next state
+ ******************************************/
+ void initialize();
+
+ private:
+ /****************************************
+ * [% stateClassName %]
+ * Private constructor
+ ****************************************/
+ [% stateClassName %]();
+ };
+};
+#endif // __[% stateClassName %]__
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 %]
+}
diff --git a/scripts/SMCodeGen/templates/stateMachineTmpls/stateFactory.h.tt b/scripts/SMCodeGen/templates/stateMachineTmpls/stateFactory.h.tt
new file mode 100644
index 0000000..5367e85
--- /dev/null
+++ b/scripts/SMCodeGen/templates/stateMachineTmpls/stateFactory.h.tt
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2019-present, Infosys Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**************************************
+ *
+ * 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.h.tt>
+ **************************************/
+
+#ifndef __StateFactory__
+#define __StateFactory__
+
+namespace mme {
+ class StateFactory {
+ public:
+ /******************************************
+ * Instance
+ * Creates static instance for the state
+ *******************************************/
+ static StateFactory* Instance();
+
+ /*****************************************
+ * StateFactory
+ * Destructor
+ *****************************************/
+ ~StateFactory();
+
+ /******************************************
+ * initialize
+ * Initializes action handlers for the state
+ * and next state
+ ******************************************/
+ void initialize();
+
+ private:
+ /****************************************
+ * StateFactory
+ * Private constructor
+ ****************************************/
+ StateFactory();
+
+ };
+};
+#endif // __StateFactory__