OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
audit_list.h
Go to the documentation of this file.
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 
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
13 template<class List, class Iterator>
14 bool AuditList(List &list, Iterator old_first, Iterator old_last,
15  Iterator new_first, Iterator new_last) {
16  bool ret = false;
17  Iterator old_iterator = old_first;
18  Iterator new_iterator = new_first;
19  while (old_iterator != old_last && new_iterator != new_last) {
20  if (old_iterator->IsLess(new_iterator.operator->())) {
21  Iterator bkp = old_iterator++;
22  list.Remove(bkp);
23  ret = true;
24  } else if (new_iterator->IsLess(old_iterator.operator->())) {
25  Iterator bkp = new_iterator++;
26  list.Insert(bkp.operator->());
27  ret = true;
28  } else {
29  Iterator old_bkp = old_iterator++;
30  Iterator new_bkp = new_iterator++;
31  list.Update(old_bkp.operator->(), new_bkp.operator->());
32  ret = true;
33  }
34  }
35 
36  while (old_iterator != old_last) {
37  Iterator bkp = old_iterator++;
38  list.Remove(bkp);
39  ret = true;
40  }
41 
42  while (new_iterator != new_last) {
43  Iterator bkp = new_iterator++;
44  list.Insert(bkp.operator->());
45  ret = true;
46  }
47 
48  return ret;
49 }
50 #endif
bool AuditList(List &list, Iterator old_first, Iterator old_last, Iterator new_first, Iterator new_last)
Definition: audit_list.h:14