MME2 changes - Propped commits from openmme/paging branch. Added scripts
for code gen
Change-Id: Ie55032217232214ac8544ca76ea34335205329e4
diff --git a/scripts/SMCodeGen/README.txt b/scripts/SMCodeGen/README.txt
new file mode 100644
index 0000000..66c7ac3
--- /dev/null
+++ b/scripts/SMCodeGen/README.txt
@@ -0,0 +1,28 @@
+Requirements:
+1.Python3.6.
+2.Install the template-toolkit package.
+ a. pip install Template-Toolkit-Python or
+ b. git clone https://github.com/lmr/Template-Toolkit-Python, and set the path of the package in the codeGen.py script [as argument in sys.path.append]
+
+Inputs:
+ 2 Json files:
+ generateItem.json - Defines path of templates, the class type to be generated(State/actionHandler/Enum), output directory to be produced.
+ stateMachineAppModel.json - Defines procedures, states for each procedure, event for each state, actions to be taken under each event and nextstate of the procedure.
+
+ Existing actionHandler.h and attachActionHandlers.cpp,detachActionHandlers.cpp,s1ReleaseActionHandlers.cpp files from <top-dir>/include/mme-app/actionHandlers and <top-dir>/src/mme-app/actionHandlers respectively.
+ Place it in output directories as the output produced should be merged with existing file properly.
+
+Output:
+ 1. mme states .cpp and header files. Copy to <top-dir>/src/mme-app/mme-states and <top-dir>/include/mme-app/mme-states
+ 2. stateFactory.h and stateFactory.cpp Copy to <top-dir>/src/mme-app/mme-states and <top-dir>/include/mme-app/mme-states
+ 3. actionHandlers
+ actionHandler.h and actionHandler source files per procedure (eg: attachActionHandlers.cpp, detachActionHandlers.cpp )
+ actionHandler.h should be placed in <top-dir>/include/mme-app/actionHandlers
+ attachActionHandler.cpp should placed in <top-dir>/src/mme-app/actionHandlers
+ 4. enums used by the MME state machine - <top-dir>/include/stateMachineFwk
+
+Execution:
+-Run the below command:
+ python codeGen.py
+
+
diff --git a/scripts/SMCodeGen/__init__.py b/scripts/SMCodeGen/__init__.py
new file mode 100644
index 0000000..95b7eed
--- /dev/null
+++ b/scripts/SMCodeGen/__init__.py
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2019, Infosys Ltd.
+#
+# 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.
+#
diff --git a/scripts/SMCodeGen/codeGen.py b/scripts/SMCodeGen/codeGen.py
new file mode 100644
index 0000000..15259be
--- /dev/null
+++ b/scripts/SMCodeGen/codeGen.py
@@ -0,0 +1,79 @@
+#
+# Copyright (c) 2019, Infosys Ltd.
+#
+# 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.
+#
+
+import json, sys, os
+from os.path import join
+import utils
+
+with open('dataModels/stateMachineAppModel.json') as jsonFile:
+ stateMachineAppModelJSON = json.load(jsonFile)
+with open('dataModels/ctxtManagerAppModel.json') as jsonFile:
+ contextMgrAppModelJSON = json.load(jsonFile)
+
+def processTemplate(templateIp):
+ from template import Template
+
+ utils.outputFileName = ''
+ if utils.outputFileKeyword != '':
+ utils.outputFileName = utils.getFileName(templateIp[utils.outputFileKeyword])
+ if utils.outputFile != '':
+ utils.outputFileName = utils.outputFileName + utils.outputFile
+
+ utils.outputFileName = utils.outputFileName + utils.outputFileExt
+
+ tt = Template({'EVAL_PYTHON':1, 'AUTO_RESET':1})
+ op = tt.process(utils.ttFileName, {'TemplateInputVar' : templateIp})
+ utils.WriteFile(utils.outputDir, utils.outputFileName, op, utils.mode)
+
+def getTemplateIn(appModelItems, depth):
+ depthChanged = False
+
+ if (depth == 0):
+ print(appModelItems)
+ processTemplate(appModelItems)
+ return
+
+ if depthChanged == False:
+ depth = depth - 1
+ depthChanged = True
+
+ for item in appModelItems:
+ getTemplateIn(item, depth)
+
+def genCppCode(genModel, appModelJSON):
+ for item in genModel:
+ keyWord = item["appModelKeyword"]
+ depth = item["appModelValueDepth"]
+ utils.ttFileName = item["templateFile"]
+ utils.outputDir = item["outputPath"]
+ utils.outputFile = item["outputFile"]
+ utils.outputFileKeyword = item["outputFileKey"]
+ utils.outputFileExt = item["outputFileExt"]
+ utils.mode = item["mode"]
+
+ if not os.path.exists(utils.outputDir):
+ os.makedirs(utils.outputDir)
+
+ appModelItems = utils.get_key_values(appModelJSON, keyWord)
+ getTemplateIn(appModelItems, depth)
+
+with open('dataModels/generationItem.json') as JSONFile:
+ GenItemJSON = json.load(JSONFile)
+ if 'Model1' in GenItemJSON:
+ genCppCode(GenItemJSON['Model1'], stateMachineAppModelJSON)
+ if "Model2" in GenItemJSON:
+ genCppCode(GenItemJSON['Model2'], contextMgrAppModelJSON)
+
diff --git a/scripts/SMCodeGen/dataModels/ctxtManagerAppModel.json b/scripts/SMCodeGen/dataModels/ctxtManagerAppModel.json
new file mode 100644
index 0000000..0d6c83e
--- /dev/null
+++ b/scripts/SMCodeGen/dataModels/ctxtManagerAppModel.json
@@ -0,0 +1,309 @@
+{
+"DataStore":
+ {
+ "DataGroups":[
+ {
+ "DgName":"SubscriberData",
+ "PoolSize":"8000",
+ "DataBlocks":[
+ {
+ "BlockName":"UEContext",
+ "BlockType":"Permanent",
+ "Parent":"None",
+ "Children":["MmContext", "SessionContext"],
+ "PoolSize":"8000",
+ "Cardinality":"1",
+ "Data":[
+ {
+ "Name": "enbFd",
+ "Type": "int",
+ "Key":"No"
+ },
+ {
+ "Name": "s1apEnbUeId",
+ "Type": "int",
+ "Key":"No"
+ },
+ {
+ "Name": "subscriptionStatus",
+ "Type": "int",
+ "Key":"No"
+ },
+ {
+ "Name": "netAccessMode",
+ "Type": "int",
+ "Key":"No"
+ },
+ {
+ "Name": "contextID",
+ "Type": "uint32_t",
+ "Key":"No"
+ },
+ {
+ "Name": "rauTauTimer",
+ "Type": "unsigned int",
+ "Key":"No"
+ },
+ {
+ "Name": "accessRestrictionData",
+ "Type": "unsigned int",
+ "Key":"No"
+ },
+ {
+ "Name": "imsi",
+ "Type": "DigitRegister15",
+ "Key":"Yes"
+ },
+ {
+ "Name": "mTmsi",
+ "Type": "uint32_t",
+ "Key":"Yes"
+ },
+ {
+ "Name": "msisdn",
+ "Type": "DigitRegister15",
+ "Key":"No"
+ },
+ {
+ "Name": "dwnLnkSeqNo",
+ "Type": "unsigned short",
+ "Key":"No"
+ },
+ {
+ "Name": "upLnkSeqNo",
+ "Type": "unsigned short",
+ "Key":"No"
+ },
+ {
+ "Name": "ueState",
+ "Type": "UE_State_e",
+ "Key":"No"
+ },
+ {
+ "Name": "tai",
+ "Type": "Tai",
+ "Key":"No"
+ },
+ {
+ "Name": "utranCgi",
+ "Type": "Cgi",
+ "Key":"No"
+ },
+ {
+ "Name": "msNetCapab",
+ "Type": "Ms_net_capab",
+ "Key":"No"
+ },
+ {
+ "Name": "ueNetCapab",
+ "Type": "Ue_net_capab",
+ "Key":"No"
+ },
+ {
+ "Name": "ueSecInfo",
+ "Type": "Secinfo",
+ "Key":"No"
+ },
+ {
+ "Name": "ambr",
+ "Type": "Ambr",
+ "Key":"No"
+ },
+ {
+ "Name": "aiaSecInfo",
+ "Type": "E_utran_sec_vector",
+ "Key":"No"
+ }
+ ]
+ },
+ {
+ "BlockName":"MmContext",
+ "BlockType":"Permanent",
+ "Parent":"UEContext",
+ "Children":[],
+ "PoolSize":"8000",
+ "Cardinality":"1",
+ "Data":[
+ {
+ "Name": "mmState",
+ "Type": "EmmState",
+ "Key":"No"
+ }
+ ]
+ },
+ {
+ "BlockName":"SessionContext",
+ "BlockType":"Permanent",
+ "Parent":"UEContext",
+ "Children":["BearerContext"],
+ "PoolSize":"8000",
+ "Cardinality":"3",
+ "Data":[
+ {
+ "Name": "sessionId",
+ "Type": "uint8_t",
+ "Key" : "No"
+ },
+ {
+ "Name": "s11SgwCtrlFteid",
+ "Type": "Fteid",
+ "Key":"No"
+ },
+ {
+ "Name": "s5S8PgwCtrlFteid",
+ "Type": "Fteid",
+ "Key":"No"
+ },
+ {
+ "Name": "pdnAddr",
+ "Type": "Paa",
+ "Key":"No"
+ },
+ {
+ "Name": "accessPtName",
+ "Type": "Apn_name",
+ "Key":"No"
+ },
+ {
+ "Name": "apnConfigProfileCtxId",
+ "Type": "unsigned int",
+ "Key":"No"
+ }
+ ]
+ },
+ {
+ "BlockName":"BearerContext",
+ "BlockType":"Permanent",
+ "Parent":"SessionContext",
+ "PoolSize":"8000",
+ "Cardinality":"11",
+ "Data":[
+ {
+ "Name": "s1uSgwUserFteid",
+ "Type": "Fteid",
+ "Key":"No"
+ },
+ {
+ "Name": "s5S8PgwUserFteid",
+ "Type": "Fteid",
+ "Key":"No"
+ },
+ {
+ "Name": "s1uEnbUserFteid",
+ "Type": "Fteid",
+ "Key":"No"
+ },
+ {
+ "Name": "bearerId",
+ "Type": "unsigned char",
+ "Key":"No"
+ }
+ ]
+ },
+ {
+ "BlockName":"MmeProcedureCtxt",
+ "BlockType":"Temporary",
+ "PoolSize":"8000",
+ "Cardinality":"1",
+ "Data":[
+ {
+ "Name": "ctxtType",
+ "Type": "ProcedureType",
+ "Key":"No"
+ },
+ {
+ "Name": "mmeErrorCause",
+ "Type": "MmeErrorCause",
+ "Key":"No"
+ },
+ {
+ "Name": "attachType",
+ "Type": "AttachType",
+ "Key":"No"
+ },
+ {
+ "Name": "pti",
+ "Type": "uint8_t",
+ "Key":"No"
+ },
+ {
+ "Name": "esmInfoTxRequired",
+ "Type": "bool",
+ "Key":"No"
+ }
+ ]
+ },
+ {
+ "BlockName":"MmeDetachProcedureCtxt",
+ "BlockType":"Temporary",
+ "PoolSize":"8000",
+ "Cardinality":"1",
+ "Data":[
+ {
+ "Name": "detachType",
+ "Type": "DetachType",
+ "Key":"No"
+ },
+ {
+ "Name": "cancellationType",
+ "Type": "CancellationType",
+ "Key":"No"
+ }
+ ]
+ },
+ {
+ "BlockName":"MmeSvcReqProcedureCtxt",
+ "BlockType":"Temporary",
+ "PoolSize":"8000",
+ "Cardinality":"1",
+ "Data":[
+ {
+ "Name": "pagingTrigger",
+ "Type": "PagingTrigger",
+ "Key":"No"
+ },
+ {
+ "Name": "epsBearerId",
+ "Type": "uint8_t",
+ "Key":"No"
+ },
+ {
+ "Name": "arp",
+ "Type": "Arp",
+ "Key":"No"
+ },
+ {
+ "Name": "ddnSeqNum",
+ "Type": "uint32_t",
+ "Key":"No"
+ }
+ ]
+ },
+ {
+ "BlockName":"MmeTauProcedureCtxt",
+ "BlockType":"Temporary",
+ "PoolSize":"8000",
+ "Cardinality":"1",
+ "Data":[
+ {
+ "Name": "s1apEnbUeId",
+ "Type": "int",
+ "Key":"No"
+ },
+ {
+ "Name": "tai",
+ "Type": "Tai",
+ "Key":"No"
+ },
+ {
+ "Name": "enbFd",
+ "Type": "int",
+ "Key":"No"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/scripts/SMCodeGen/dataModels/generationItem.json b/scripts/SMCodeGen/dataModels/generationItem.json
new file mode 100644
index 0000000..c14504a
--- /dev/null
+++ b/scripts/SMCodeGen/dataModels/generationItem.json
@@ -0,0 +1,118 @@
+{
+ "Model1" :
+ [
+ {
+ "appModelKeyword" : "States",
+ "appModelValueDepth" : 2,
+ "templateFile" : "templates/stateMachineTmpls/state.h.tt",
+ "outputPath" : "output/states/headers",
+ "outputFile": "",
+ "outputFileKey": "Name",
+ "outputFileExt" : ".h",
+ "mode" : "overwrite"
+ },
+ {
+ "appModelKeyword" : "States",
+ "appModelValueDepth" : 2,
+ "templateFile" : "templates/stateMachineTmpls/state.cpp.tt",
+ "outputPath" : "output/states/cpp",
+ "outputFile": "",
+ "outputFileKey": "Name",
+ "outputFileExt" : ".cpp",
+ "mode" : "overwrite"
+ },
+ {
+ "appModelKeyword" : "Procedures",
+ "appModelValueDepth" : 0,
+ "templateFile" : "templates/stateMachineTmpls/enum.tt",
+ "outputPath" : "output/enums",
+ "outputFile": "smEnumTypes",
+ "outputFileKey": "",
+ "outputFileExt" : ".h",
+ "mode" : "overwrite"
+ },
+ {
+ "appModelKeyword" : "Actions",
+ "appModelValueDepth" : 0,
+ "templateFile" : "templates/stateMachineTmpls/actionHandlers.h.tt",
+ "outputPath" : "output/actionHandler/header",
+ "outputFile": "actionHandlers",
+ "outputFileKey": "",
+ "outputFileExt" : ".h",
+ "mode" : "overwrite"
+ },
+ {
+ "appModelKeyword" : "Procedures",
+ "appModelValueDepth" : 2,
+ "templateFile" : "templates/stateMachineTmpls/actionHandlers.cpp.tt",
+ "outputPath" : "output/actionHandler/cpp",
+ "outputFile": "ActionHandlers",
+ "outputFileKey": "Name",
+ "outputFileExt" : ".cpp",
+ "mode" : "append"
+ },
+ {
+ "appModelKeyword" : "States",
+ "appModelValueDepth" : 0,
+ "templateFile" : "templates/stateMachineTmpls/stateFactory.cpp.tt",
+ "outputPath" : "output/states/cpp",
+ "outputFile": "stateFactory",
+ "outputFileKey": "",
+ "outputFileExt" : ".cpp",
+ "mode" : "overwrite"
+ },
+ {
+ "appModelKeyword" : "States",
+ "appModelValueDepth" : 0,
+ "templateFile" : "templates/stateMachineTmpls/stateFactory.h.tt",
+ "outputPath" : "output/states/headers",
+ "outputFile": "stateFactory",
+ "outputFileKey": "",
+ "outputFileExt" : ".h",
+ "mode" : "overwrite"
+ }
+ ],
+ "Model2" :
+ [
+ {
+ "appModelKeyword" : "DataBlocks",
+ "appModelValueDepth" : 2,
+ "templateFile" : "templates/ctxtManagerTmpls/blockPoolManager.h.tt",
+ "outputPath" : "output/contextManager/dg/headers",
+ "outputFile": "Manager",
+ "outputFileKey": "BlockName",
+ "outputFileExt" : ".h",
+ "mode" : "overwrite"
+ },
+ {
+ "appModelKeyword" : "DataBlocks",
+ "appModelValueDepth" : 2,
+ "templateFile" : "templates/ctxtManagerTmpls/blockPoolManager.cpp.tt",
+ "outputPath" : "output/contextManager/dg/cpp",
+ "outputFile": "Manager",
+ "outputFileKey": "BlockName",
+ "outputFileExt" : ".cpp",
+ "mode" : "overwrite"
+ },
+ {
+ "appModelKeyword" : "DataGroups",
+ "appModelValueDepth" : 2,
+ "templateFile" : "templates/ctxtManagerTmpls/subsDataGroupManager.h.tt",
+ "outputPath" : "output/contextManager/dg/headers",
+ "outputFile": "subsDataGroupManager",
+ "outputFileKey": "",
+ "outputFileExt" : ".h",
+ "mode" : "overwrite"
+ },
+ {
+ "appModelKeyword" : "DataGroups",
+ "appModelValueDepth" : 2,
+ "templateFile" : "templates/ctxtManagerTmpls/subsDataGroupManager.cpp.tt",
+ "outputPath" : "output/contextManager/dg/cpp",
+ "outputFile": "subsDataGroupManager",
+ "outputFileKey": "",
+ "outputFileExt" : ".cpp",
+ "mode" : "overwrite"
+ }
+ ]
+}
diff --git a/scripts/SMCodeGen/dataModels/stateMachineAppModel.json b/scripts/SMCodeGen/dataModels/stateMachineAppModel.json
new file mode 100644
index 0000000..d72b6d2
--- /dev/null
+++ b/scripts/SMCodeGen/dataModels/stateMachineAppModel.json
@@ -0,0 +1,540 @@
+{
+ "Application":{
+ "Name":"mme",
+ "Procedures":[
+ {
+ "Name":"DEFAULT_MME_PROCEDURE",
+ "States":[
+ {
+ "Name":"default_mme_state",
+ "Events":[
+ {
+ "Name":"ATTACH_REQ_FROM_UE",
+ "Actions":[
+ "DEFAULT_ATTACH_REQ_HANDLER"
+ ],
+ "NextState":"end_state"
+ },
+ {
+ "Name":"DETACH_REQ_FROM_UE",
+ "Actions":[
+ "DEFAULT_DETACH_REQ_HANDLER"
+ ],
+ "NextState":"end_state"
+ },
+ {
+ "Name":"S1_REL_REQ_FROM_UE",
+ "Actions":[
+ "DEFAULT_S1_RELEASE_REQ_HANDLER"
+ ],
+ "NextState":"end_state"
+ },
+ {
+ "Name":"DDN_FROM_SGW",
+ "Actions":[
+ "DEFAULT_DDN_HANDLER"
+ ],
+ "NextState":"end_state"
+ },
+ {
+ "Name":"SERVICE_REQUEST_FROM_UE",
+ "Actions":[
+ "DEFAULT_SERVICE_REQ_HANDLER"
+ ],
+ "NextState":"end_state"
+ },
+ {
+ "Name":"CLR_FROM_HSS",
+ "Actions":[
+ "DEFAULT_CANCEL_LOC_REQ_HANDLER"
+ ],
+ "NextState":"end_state"
+ },
+ {
+ "Name":"TAU_REQUEST_FROM_UE",
+ "Actions":[
+ "DEFAULT_TAU_REQ_HANDLER"
+ ],
+ "NextState":"end_state"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Name":"ATTACH",
+ "States":[
+ {
+ "Name":"attach_start",
+ "Events":[
+ {
+ "Name":"VALIDATE_IMSI",
+ "Actions":[
+ "VALIDATE_IMSI_IN_UE_CONTEXT"
+ ],
+ "NextState":"attach_wf_imsi_validate_action"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_imsi_validate_action",
+ "Events":[
+ {
+ "Name":"IMSI_VALIDATION_SUCCESS",
+ "Actions":[
+ "SEND_AIR_TO_HSS"
+ ],
+ "NextState":"attach_wf_aia"
+ },
+ {
+ "Name":"IMSI_VALIDATION_FAILURE",
+ "Actions":[
+ "SEND_IDENTITY_REQUEST_TO_UE"
+ ],
+ "NextState":"attach_wf_identity_response"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_aia",
+ "Events":[
+ {
+ "Name":"AIA_FROM_HSS",
+ "Actions":[
+ "PROCESS_AIA",
+ "AUTH_REQ_TO_UE"
+ ],
+ "NextState":"attach_wf_auth_resp"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_identity_response",
+ "Events":[
+ {
+ "Name":"IDENTITY_RESPONSE_FROM_UE",
+ "Actions":[
+ "PROCESS_IDENTITY_RESPONSE",
+ "SEND_AIR_TO_HSS"
+ ],
+ "NextState":"attach_wf_aia"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_auth_resp",
+ "Events":[
+ {
+ "Name":"AUTH_RESP_FROM_UE",
+ "Actions":[
+ "AUTH_RESPONSE_VALIDATE"
+ ],
+ "NextState":"attach_wf_auth_resp_validate"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_auth_resp_validate",
+ "Events":[
+ {
+ "Name":"AUTH_RESP_SUCCESS",
+ "Actions":[
+ "SEC_MODE_CMD_TO_UE"
+ ],
+ "NextState":"attach_wf_sec_cmp"
+ },
+ {
+ "Name":"AUTH_RESP_SYNC_FAILURE",
+ "Actions":[
+ "SEND_AIR_TO_HSS"
+ ],
+ "NextState":"attach_wf_aia"
+ },
+ {
+ "Name":"AUTH_RESP_FAILURE",
+ "Actions":[
+ "SEND_AUTH_REJECT"
+ ],
+ "NextState":"end_state"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_sec_cmp",
+ "Events":[
+ {
+ "Name":"SEC_MODE_RESP_FROM_UE",
+ "Actions":[
+ "PROCESS_SEC_MODE_RESP",
+ "CHECK_ESM_INFO_REQ_REQUIRED"
+ ],
+ "NextState":"attach_wf_esm_info_check"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_esm_info_check",
+ "Events":[
+ {
+ "Name":"ESM_INFO_REQUIRED",
+ "Actions":[
+ "SEND_ESM_INFO_REQ_TO_UE"
+ ],
+ "NextState":"attach_wf_esm_info_resp"
+ },
+ {
+ "Name":"ESM_INFO_NOT_REQUIRED",
+ "Actions":[
+ "SEND_ULR_TO_HSS"
+ ],
+ "NextState":"attach_wf_ula"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_esm_info_resp",
+ "Events":[
+ {
+ "Name":"ESM_INFO_RESP_FROM_UE",
+ "Actions":[
+ "PROCESS_ESM_INFO_RESP",
+ "SEND_ULR_TO_HSS"
+ ],
+ "NextState":"attach_wf_ula"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_ula",
+ "Events":[
+ {
+ "Name":"ULA_FROM_HSS",
+ "Actions":[
+ "PROCESS_ULA",
+ "CS_REQ_TO_SGW"
+ ],
+ "NextState":"attach_wf_cs_resp"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_cs_resp",
+ "Events":[
+ {
+ "Name":"CS_RESP_FROM_SGW",
+ "Actions":[
+ "PROCESS_CS_RESP",
+ "SEND_INIT_CTXT_REQ_TO_UE"
+ ],
+ "NextState":"attach_wf_init_ctxt_resp_att_cmp"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_init_ctxt_resp_att_cmp",
+ "Events":[
+ {
+ "Name":"INIT_CTXT_RESP_FROM_UE",
+ "Actions":[
+ "PROCESS_INIT_CTXT_RESP"
+ ],
+ "NextState":"attach_wf_att_cmp"
+ },
+ {
+ "Name":"ATT_CMP_FROM_UE",
+ "Actions":[
+ "PROCESS_ATTACH_CMP_FROM_UE"
+ ],
+ "NextState":"attach_wf_init_ctxt_resp"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_init_ctxt_resp",
+ "Events":[
+ {
+ "Name":"INIT_CTXT_RESP_FROM_UE",
+ "Actions":[
+ "PROCESS_INIT_CTXT_RESP",
+ "SEND_MB_REQ_TO_SGW"
+ ],
+ "NextState":"attach_wf_mb_resp"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_att_cmp",
+ "Events":[
+ {
+ "Name":"ATT_CMP_FROM_UE",
+ "Actions":[
+ "PROCESS_ATTACH_CMP_FROM_UE",
+ "SEND_MB_REQ_TO_SGW"
+ ],
+ "NextState":"attach_wf_mb_resp"
+ }
+ ]
+ },
+ {
+ "Name":"attach_wf_mb_resp",
+ "Events":[
+ {
+ "Name":"MB_RESP_FROM_SGW",
+ "Actions":[
+ "PROCESS_MB_RESP",
+ "ATTACH_DONE"
+ ],
+ "NextState":"end_state"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Name":"UE_INIT_DETACH",
+ "States":[
+ {
+ "Name":"detach_start",
+ "Events":[
+ {
+ "Name":"DETACH_REQ_FROM_UE",
+ "Actions":[
+ "DEL_SESSION_REQ"
+ ],
+ "NextState":"detach_wf_del_session_resp"
+ }
+ ]
+ },
+ {
+ "Name":"detach_wf_del_session_resp",
+ "Events":[
+ {
+ "Name":"DEL_SESSION_RESP_FROM_SGW",
+ "Actions":[
+ "PROCESS_DEL_SESSION_RESP",
+ "DETACH_ACCEPT_TO_UE"
+ ],
+ "NextState":"end_state"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Name":"S1_RELEASE",
+ "States":[
+ {
+ "Name":"s1_release_start",
+ "Events":[
+ {
+ "Name":"S1_REL_REQ_FROM_UE",
+ "Actions":[
+ "SEND_REL_AB_REQ_TO_SGW"
+ ],
+ "NextState":"s1_release_wf_release_access_bearer_resp"
+ }
+ ]
+ },
+ {
+ "Name":"s1_release_wf_release_access_bearer_resp",
+ "Events":[
+ {
+ "Name":"REL_AB_RESP_FROM_SGW",
+ "Actions":[
+ "PROCESS_REL_AB_RESP_FROM_SGW",
+ "SEND_S1_REL_CMD_TO_UE"
+ ],
+ "NextState":"s1_release_wf_ue_ctxt_release_comp"
+ }
+ ]
+ },
+ {
+ "Name":"s1_release_wf_ue_ctxt_release_comp",
+ "Events":[
+ {
+ "Name":"UE_CTXT_REL_COMP_FROM_ENB",
+ "Actions":[
+ "PROCESS_UE_CTXT_REL_COMP"
+ ],
+ "NextState":"end_state"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Name":"NETWORK_INIT_DETACH",
+ "States":[
+ {
+ "Name":"ni_detach_start",
+ "Events":[
+ {
+ "Name":"CLR_FROM_HSS",
+ "Actions":[
+ "NI_DETACH_REQ_TO_UE",
+ "DEL_SESSION_REQ"
+ ],
+ "NextState":"ni_detach_wf_det_accpt_del_sess_resp"
+ }
+ ]
+ },
+ {
+ "Name":"ni_detach_wf_det_accpt_del_sess_resp",
+ "Events":[
+ {
+ "Name":"DETACH_ACCEPT_FROM_UE",
+ "Actions":[
+ "PROCESS_DETACH_ACCEPT_FROM_UE"
+ ],
+ "NextState":"ni_detach_wf_del_sess_resp"
+ },
+ {
+ "Name":"DEL_SESSION_RESP_FROM_SGW",
+ "Actions":[
+ "PROCESS_DEL_SESSION_RESP"
+ ],
+ "NextState":"ni_detach_wf_detach_accept"
+ }
+ ]
+ },
+ {
+ "Name":"ni_detach_wf_del_sess_resp",
+ "Events":[
+ {
+ "Name":"DEL_SESSION_RESP_FROM_SGW",
+ "Actions":[
+ "PROCESS_DEL_SESSION_RESP",
+ "SEND_S1_REL_CMD_TO_UE"
+ ],
+ "NextState":"ni_detach_wf_s1_rel_comp"
+ }
+ ]
+ },
+ {
+ "Name":"ni_detach_wf_detach_accept",
+ "Events":[
+ {
+ "Name":"DETACH_ACCEPT_FROM_UE",
+ "Actions":[
+ "PROCESS_DETACH_ACCEPT_FROM_UE",
+ "SEND_S1_REL_CMD_TO_UE_FOR_DETACH"
+ ],
+ "NextState":"ni_detach_wf_s1_rel_comp"
+ }
+ ]
+ },
+ {
+ "Name":"ni_detach_wf_s1_rel_comp",
+ "Events":[
+ {
+ "Name":"UE_CTXT_REL_COMP_FROM_ENB",
+ "Actions":[
+ "PROCESS_UE_CTXT_REL_COMP_FOR_DETACH"
+ ],
+ "NextState":"end_state"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Name":"SERVICE_REQUEST",
+ "States":[
+ {
+ "Name":"paging_start",
+ "Events":[
+ {
+ "Name":"DDN_FROM_SGW",
+ "Actions":[
+ "SEND_PAGING_REQ_TO_UE"
+ ],
+ "NextState":"paging_wf_service_req"
+ }
+ ]
+ },
+ {
+ "Name":"service_request_start",
+ "Events":[
+ {
+ "Name":"SERVICE_REQUEST_FROM_UE",
+ "Actions":[
+ "PROCESS_SERVICE_REQUEST",
+ "PERFORM_AUTH_AND_SEC_CHECK"
+ ],
+ "NextState":"service_request_wf_auth_and_sec_check_cmp"
+ }
+ ]
+ },
+ {
+ "Name":"paging_wf_service_req",
+ "Events":[
+ {
+ "Name":"SERVICE_REQUEST_FROM_UE",
+ "Actions":[
+ "PROCESS_SERVICE_REQUEST",
+ "SEND_DDN_ACK_TO_SGW",
+ "PERFORM_AUTH_AND_SEC_CHECK"
+ ],
+ "NextState":"service_request_wf_auth_and_sec_check_cmp"
+ }
+ ]
+ },
+ {
+ "Name":"service_request_wf_auth_and_sec_check_cmp",
+ "Events":[
+ {
+ "Name":"AUTH_AND_SEC_CHECK_COMPLETE",
+ "Actions":[
+ "SEND_INIT_CTXT_REQ_TO_UE_SVC_REQ"
+ ],
+ "NextState":"service_request_wf_init_ctxt_resp"
+ }
+ ]
+ },
+ {
+ "Name":"service_request_wf_init_ctxt_resp",
+ "Events":[
+ {
+ "Name":"INIT_CTXT_RESP_FROM_UE",
+ "Actions":[
+ "PROCESS_INIT_CTXT_RESP_SVC_REQ",
+ "SEND_MB_REQ_TO_SGW_SVC_REQ"
+ ],
+ "NextState":"service_request_wf_mb_resp"
+ }
+ ]
+ },
+ {
+ "Name":"service_request_wf_mb_resp",
+ "Events":[
+ {
+ "Name":"MB_RESP_FROM_SGW",
+ "Actions":[
+ "PROCESS_MB_RESP_SVC_REQ"
+ ],
+ "NextState":"end_state"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Name":"TAU",
+ "States":[
+ {
+ "Name":"tau_start",
+ "Events":[
+ {
+ "Name":"TAU_REQUEST_FROM_UE",
+ "Actions":[
+ "SEND_TAU_RESPONSE_TO_UE"
+ ],
+ "NextState":"end_state"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
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__
diff --git a/scripts/SMCodeGen/utils.py b/scripts/SMCodeGen/utils.py
new file mode 100644
index 0000000..49e49cc
--- /dev/null
+++ b/scripts/SMCodeGen/utils.py
@@ -0,0 +1,96 @@
+#
+# Copyright (c) 2019, Infosys Ltd.
+#
+# 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.
+#
+
+import os
+from os import listdir
+from os.path import isfile, join
+
+# Globals
+ttFileName = ''
+outputDir = ''
+outputFile = ''
+outputFileKeyword = ''
+outputFileExt = ''
+outputFileName = ''
+mode = ''
+
+def WriteFile(dirName, fileName, content, fileMode):
+ filePath = join(dirName, fileName)
+ accessMode = 'w+'
+ if (fileMode == 'append') :
+ accessMode = 'a+'
+ with open(filePath, accessMode) as File:
+ File.write(content)
+
+def readFile(fileName):
+ if os.path.exists(fileName):
+ with open(fileName, 'r') as file:
+ return file.read()
+ return
+
+def searchWordInDir(path, word):
+ files = [f for f in listdir(path) if isfile(join(path, f))]
+ for i in files:
+ fileContent = open(join(path, i)).read()
+ if word in fileContent:
+ return True
+ return False
+
+
+def searchWordInFile(path, fileName, word):
+ if os.path.exists(join(path, fileName)):
+ with open(join(path, fileName)) as File:
+ fileContent = File.read()
+ if word in fileContent:
+ return True
+ return False
+
+def isFileEmpty(path, fileName):
+ fullPath = join(path, fileName)
+ if os.path.exists(fullPath):
+ if os.stat(fullPath).st_size > 0:
+ return 0
+ else :
+ return 1
+ return 1
+
+def getFileName(str):
+ if (str.find("_") != -1):
+ str = str.lower()
+ tokens = [x.capitalize() for x in str.split("_")]
+ fileName = ''
+ fileName = fileName.join(tokens)
+ return (fileName[0].lower() + fileName[1:])
+
+ return (str[0].lower() + str[1:])
+
+def get_key_values(obj, key):
+ arr = []
+
+ def extract(obj, arr, key):
+ if isinstance(obj, dict):
+ for k,v in obj.items():
+ if k == key:
+ arr.append(v)
+ elif isinstance(v, (dict, list)):
+ extract(v, arr, key)
+ elif isinstance(obj,list):
+ for item in obj:
+ extract(item, arr, key)
+ return arr
+
+ results = extract (obj, arr, key)
+ return results