Line data Source code
1 : /* 2 : * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef vnsw_agent_audit_list_hpp 6 : #define vnsw_agent_audit_list_hpp 7 : 8 : ///////////////////////////////////////////////////////////////////////////// 9 : // Template function to audit two lists. This is used to synchronize the 10 : // operational and config list for Floating-IP, Service-Vlans, Static Routes 11 : // and SG List 12 : ///////////////////////////////////////////////////////////////////////////// 13 : template<class List, class Iterator> 14 780 : bool AuditList(List &list, Iterator old_first, Iterator old_last, 15 : Iterator new_first, Iterator new_last) { 16 780 : bool ret = false; 17 780 : Iterator old_iterator = old_first; 18 780 : Iterator new_iterator = new_first; 19 816 : while (old_iterator != old_last && new_iterator != new_last) { 20 36 : if (old_iterator->IsLess(new_iterator.operator->())) { 21 0 : Iterator bkp = old_iterator++; 22 0 : list.Remove(bkp); 23 0 : ret = true; 24 36 : } else if (new_iterator->IsLess(old_iterator.operator->())) { 25 0 : Iterator bkp = new_iterator++; 26 0 : list.Insert(bkp.operator->()); 27 0 : ret = true; 28 : } else { 29 36 : Iterator old_bkp = old_iterator++; 30 36 : Iterator new_bkp = new_iterator++; 31 36 : list.Update(old_bkp.operator->(), new_bkp.operator->()); 32 36 : ret = true; 33 : } 34 : } 35 : 36 824 : while (old_iterator != old_last) { 37 44 : Iterator bkp = old_iterator++; 38 44 : list.Remove(bkp); 39 44 : ret = true; 40 : } 41 : 42 824 : while (new_iterator != new_last) { 43 44 : Iterator bkp = new_iterator++; 44 44 : list.Insert(bkp.operator->()); 45 44 : ret = true; 46 : } 47 : 48 780 : return ret; 49 : } 50 : #endif