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