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