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 767 : bool AuditList(List &list, Iterator old_first, Iterator old_last, 15 : Iterator new_first, Iterator new_last) { 16 767 : bool ret = false; 17 767 : Iterator old_iterator = old_first; 18 767 : Iterator new_iterator = new_first; 19 805 : while (old_iterator != old_last && new_iterator != new_last) { 20 38 : if (old_iterator->IsLess(new_iterator.operator->())) { 21 0 : Iterator bkp = old_iterator++; 22 0 : list.Remove(bkp); 23 0 : ret = true; 24 38 : } 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 38 : Iterator old_bkp = old_iterator++; 30 38 : Iterator new_bkp = new_iterator++; 31 38 : list.Update(old_bkp.operator->(), new_bkp.operator->()); 32 38 : ret = true; 33 : } 34 : } 35 : 36 805 : while (old_iterator != old_last) { 37 38 : Iterator bkp = old_iterator++; 38 38 : list.Remove(bkp); 39 38 : ret = true; 40 : } 41 : 42 805 : while (new_iterator != new_last) { 43 38 : Iterator bkp = new_iterator++; 44 38 : list.Insert(bkp.operator->()); 45 38 : ret = true; 46 : } 47 : 48 767 : return ret; 49 : } 50 : #endif