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