| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // Copyright (c) 2000-2019 Ericsson Telecom AB // |
| // // |
| // All rights reserved. This program and the accompanying materials // |
| // are made available under the terms of the Eclipse Public License v2.0 // |
| // which accompanies this distribution, and is available at // |
| // https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html // |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////////////// |
| // Insert the following code into the module where the type dummy is defined: |
| /////////////////////////////////////////////////////////////////// |
| |
| /* |
| // THE GENERATED CODE BELOW IS EQUIVALENT WITH THE FOLLOWING MACRO: |
| // define POOL for dummy |
| #define EPTF_POOLTYPE dummy |
| #include "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| #undef EPTF_POOLTYPE |
| */ |
| |
| //////////////////////// BEGINING OF CODE ///////////////////////// |
| // GENERATED CODE, DO NOT EDIT BELOW! |
| |
| # 2 "tmp.ttcnpp" |
| |
| |
| |
| # 1 "EPTF_CLL_PoolMgmt_Functions.ttcnin" 1 |
| # 58 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| import from EPTF_CLL_QueueMgmt_Definitions all; |
| import from EPTF_CLL_QueueMgmt_Functions all; |
| # 1 "EPTF_CLL_PoolMgmt_Definitions.ttcnin" 1 |
| # 91 "EPTF_CLL_PoolMgmt_Definitions.ttcnin" |
| type record dummyPool {EPTF_FreeBusyQueue order, dummyList userData} |
| # 106 "EPTF_CLL_PoolMgmt_Definitions.ttcnin" |
| type record of dummy dummyList; |
| # 121 "EPTF_CLL_PoolMgmt_Definitions.ttcnin" |
| const dummyList c_EPTF_emptydummyList := {}; |
| # 61 "EPTF_CLL_PoolMgmt_Functions.ttcnin" 2 |
| # 82 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| const dummyPool c_EPTF_emptydummyPool := {order := c_EPTF_emptyFreeBusyQueue, userData := c_EPTF_emptydummyList} |
| # 104 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| function f_EPTF_initdummyPool(inout dummyPool pl_pool) { f_EPTF_FBQ_initFreeBusyQueue(pl_pool.order); pl_pool.userData := c_EPTF_emptydummyList; } |
| # 145 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| function f_EPTF_getNewdummy(inout dummyPool pl_pool) return integer { if (tsp_debugVerbose_PoolMgmt){ log("f_EPTF_getNew##EPTF_POOLTYPE has been called"); } var integer idx := f_EPTF_FBQ_getOrCreateFreeSlot(pl_pool.order); if (idx >= sizeof(pl_pool.userData)){ pl_pool.userData[idx]:=c_emptydummy; if (tsp_debugVerbose_PoolMgmt) { log("f_EPTF_getNew##EPTF_POOLTYPE needed to allocate new ##EPTF_POOLTYPE", " at idx:",idx, ", initialized to:",pl_pool.userData[idx]); } } return idx; } |
| # 184 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| function f_EPTF_putBackdummy(inout dummyPool pl_pool, in integer pl_qidx) return boolean { if (tsp_debugVerbose_PoolMgmt) { log("f_putBack##EPTF_POOLTYPE:", pl_qidx); } if (not f_EPTF_dummyIsBusy(pl_pool, pl_qidx)){ log("Error: f_EPTF_putBack##EPTF_POOLTYPE: clearing invalid pool item at pl_qidx:", pl_qidx,", pl_##EPTF_POOLTYPE##Pool.order.itemList[pl_qidx]:",pl_pool.order.itemList[pl_qidx]); return false; } f_EPTF_FBQ_moveFromBusyToFreeHead(pl_qidx,pl_pool.order); return true; } |
| # 219 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| function f_EPTF_getFirstdummyIndex(in dummyPool pl_pool) return integer { if (tsp_debugVerbose_PoolMgmt) { log("f_EPTF_getFirst##EPTF_POOLTYPE##Index has been called"); } if (f_EPTF_dummyPoolIsEmpty(pl_pool)){ log("Error: f_EPTF_getFirst##EPTF_POOLTYPE##Index: busy chain is empty:", pl_pool.order.status); return -1; } return pl_pool.order.status.busyStatus.head; } |
| # 250 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| function f_EPTF_getNextdummyIndex(in dummyPool pl_pool,inout integer pl_idx) return boolean { if (f_EPTF_dummyIsBusy(pl_pool,pl_idx)) { return f_EPTF_FBQ_getFwdBusyItemIdx(pl_idx,pl_pool.order); } else { return false; } } |
| # 286 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| function f_EPTF_dummyPoolIsEmpty(in dummyPool pl_pool) return boolean { if(pl_pool.order.status.busyStatus.number <=0) { return true } else { return false }; } |
| # 314 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| function f_EPTF_dummyIsBusy(in dummyPool pl_pool,in integer pl_idx) return boolean { return f_EPTF_FBQ_itemIsBusy(pl_idx,pl_pool.order); } |
| # 350 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| function f_EPTF_getdummy(in dummyPool pl_pool,in integer pl_idx,out dummy pl_poolItem) return boolean { if (not f_EPTF_dummyIsBusy(pl_pool, pl_idx)) { return false } else { pl_poolItem := pl_pool.userData[pl_idx]; return true; } } |
| # 387 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| function f_EPTF_setdummy(inout dummyPool pl_pool,in integer pl_idx,in dummy pl_poolItem) return boolean { if (not f_EPTF_dummyIsBusy(pl_pool, pl_idx)) { pl_pool.userData[pl_idx] := pl_poolItem; f_EPTF_FBQ_moveFromFreeToBusyTail(pl_idx,pl_pool.order); return true; } else {return false } } |
| # 427 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| function f_EPTF_setNewdummy(inout dummyPool pl_pool,in dummy pl_poolItem) return integer { var integer idx := f_EPTF_FBQ_getOrCreateFreeSlot(pl_pool.order); if (idx >= sizeof(pl_pool.userData)){ if (tsp_debugVerbose_PoolMgmt) { log("f_EPTF_setNew##EPTF_POOLTYPE needed to allocate new ##EPTF_POOLTYPE", " at idx:",idx, ", initialized to:",pl_poolItem); } } pl_pool.userData[idx] := pl_poolItem; f_EPTF_FBQ_moveFromFreeToBusyTail(idx,pl_pool.order); return idx; } |
| # 454 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| function f_EPTF_setValuedummy(inout dummyPool pl_pool,in integer pl_idx,in dummy pl_poolItem) { pl_pool.userData[pl_idx] := pl_poolItem; } |
| # 479 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| function f_EPTF_getValuedummy(inout dummyPool pl_pool,in integer pl_idx) return dummy { return pl_pool.userData[pl_idx]; } |
| # 519 "EPTF_CLL_PoolMgmt_Functions.ttcnin" |
| function f_EPTF_deletedummy(inout dummyPool pl_pool, in integer pl_qidx) { if (tsp_debugVerbose_PoolMgmt) { log("f_delete##EPTF_POOLTYPE:", pl_qidx); } if (not f_EPTF_dummyIsBusy(pl_pool, pl_qidx)){ log("Warning: f_EPTF_delete##EPTF_POOLTYPE: clearing free/invalid pool item at pl_qidx:", pl_qidx,", pl_##EPTF_POOLTYPE##Pool.order.itemList[pl_qidx]:",pl_pool.order.itemList[pl_qidx]); return; } f_EPTF_FBQ_moveFromBusyToFreeTail(pl_qidx,pl_pool.order); pl_pool.userData[pl_qidx] := c_emptydummy; return; } |
| # 6 "tmp.ttcnpp" 2 |
| |
| |
| |
| |
| // DO NOT EDIT ABOVE THIS LINE! |
| ////////////////////////////////////////////////////////////// |
| |
| // NOTE! |
| // Define the following constant: |
| const dummy c_emptydummy := <YOU SHOULD FILL THIS>; |
| modulepar boolean tsp_debugVerbose_PoolMgmt := false; |
| |
| //////////////////////// END OF CODE ///////////////////////// |
| |
| |
| |
| ////////////////////////////////////////////////////////////// |
| // insert the following line into your component definition: |
| ////////////////////////////////////////////////////////////// |
| var dummyPool v_dummyPool; // pool for type dummy |
| |
| ////////////////////////////////////////////////////////////// |
| // do not forget to initialize your pool with: |
| ////////////////////////////////////////////////////////////// |
| f_EPTF_initdummyPool(v_dummyPool); |
| |
| // add a new data element to the pool with the function: |
| f_EPTF_setNewdummy |
| |
| // set the value of an element in the pool with the function: |
| f_EPTF_setValuedummy |
| |
| // get the value of an element from the pool with the function: |
| f_EPTF_getValuedummy |
| |
| // remove an element from the pool with: |
| f_EPTF_deletedummy |
| |
| // get the first used element index: |
| f_EPTF_getFirstdummyIndex |
| |
| // get the next used element: |
| f_EPTF_getNextdummyIndex |
| |
| // Do not use the other functions!!! |
| // if you would like to change the user data in the pool at given pl_idx index |
| // the preferred way is to use the f_EPTF_setValuedummy function, but |
| // you may use the following structure to avoid unnecessary copying: |
| v_dummyPool.userData[pl_idx] |
| |
| |