Line data Source code
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<>, 19 : &Path::node_> PathListMember; 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 16905009 : const PathList &GetPathList() const { 48 16905009 : return path_; 49 : } 50 : 51 15456885 : PathList &GetPathList() { 52 15456885 : return path_; 53 : } 54 : 55 : private: 56 : // Path List 57 : PathList path_; 58 : 59 : DISALLOW_COPY_AND_ASSIGN(Route); 60 : }; 61 : 62 : 63 : #endif