OpenSDN source code
route.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #ifndef ctrlplane_route_h
7 #define ctrlplane_route_h
8 
9 #include <boost/intrusive/list.hpp>
10 #include <boost/intrusive/set.hpp>
11 
12 #include "db/db_entry.h"
13 #include "route/path.h"
14 
15 class Route : public DBEntry {
16 public:
17  typedef boost::intrusive::member_hook<Path,
18  boost::intrusive::list_member_hook<>,
20 
21  typedef boost::intrusive::list<Path, PathListMember> PathList;
22  typedef bool (*Compare)(const Path &path1, const Path &path2);
23 
24  Route();
25 
26  virtual ~Route();
27 
28  virtual int CompareTo(const Route &rhs) const = 0;
29 
30  bool operator<(const Route &rhs) const {
31  int res = CompareTo(rhs);
32  return res < 0;
33  }
34 
35  // Selected path
36  const Path *front() const;
37 
38  // Insert a path
39  void insert(const Path *path);
40 
41  // Remove a path
42  void remove(const Path *path);
43 
44  // Sort paths based on compare function.
45  void Sort(Compare compare, const Path *prev_front);
46 
47  const PathList &GetPathList() const {
48  return path_;
49  }
50 
52  return path_;
53  }
54 
55 private:
56  // Path List
58 
60 };
61 
62 
63 #endif
Definition: path.h:11
boost::intrusive::list_member_hook node_
Definition: path.h:25
Definition: route.h:15
virtual int CompareTo(const Route &rhs) const =0
void Sort(Compare compare, const Path *prev_front)
Definition: route.cc:41
Route()
Definition: route.cc:10
virtual ~Route()
Definition: route.cc:13
const PathList & GetPathList() const
Definition: route.h:47
bool operator<(const Route &rhs) const
Definition: route.h:30
DISALLOW_COPY_AND_ASSIGN(Route)
boost::intrusive::list< Path, PathListMember > PathList
Definition: route.h:21
boost::intrusive::member_hook< Path, boost::intrusive::list_member_hook<>, &Path::node_ > PathListMember
Definition: route.h:19
const Path * front() const
Definition: route.cc:17
void insert(const Path *path)
Definition: route.cc:25
void remove(const Path *path)
Definition: route.cc:33
PathList & GetPathList()
Definition: route.h:51
PathList path_
Definition: route.h:57
bool(* Compare)(const Path &path1, const Path &path2)
Definition: route.h:22
static int compare(const Type &lhs, const Type &rhs)