OpenSDN source code
route.cc
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 #include "route/route.h"
7 
8 #include "base/time_util.h"
9 
11 }
12 
14 }
15 
16 // Selected path
17 const Path *Route::front() const {
18  PathList::const_iterator it = path_.begin();
19  if (it == path_.end())
20  return NULL;
21  return it.operator->();
22 }
23 
24 // Insert a path
25 void Route::insert(const Path *ipath) {
26  Path *path = const_cast<Path *> (ipath);
27 
29  path_.push_back(*path);
30 }
31 
32 // Remove a path
33 void Route::remove(const Path *ipath) {
34  Path *path = const_cast<Path *> (ipath);
35 
37  PathList::const_iterator eraseIt = path_.iterator_to(*path);
38  path_.erase(eraseIt);
39 }
40 
41 void Route::Sort(Compare compare, const Path *prev_front) {
42  path_.sort(compare);
43 
45  // If the best path changes, update route's time stamp.
46  if (prev_front != front()) {
48  }
49 }
void set_last_update_at_to_now()
Definition: db_entry.cc:105
void set_last_change_at_to_now()
Definition: db_entry.cc:97
Definition: path.h:11
void set_time_stamp_usecs(uint64_t time_stamp_usecs)
Definition: path.h:19
void Sort(Compare compare, const Path *prev_front)
Definition: route.cc:41
Route()
Definition: route.cc:10
virtual ~Route()
Definition: route.cc:13
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 path_
Definition: route.h:57
static int compare(const Type &lhs, const Type &rhs)
static uint64_t UTCTimestampUsec()
Definition: time_util.h:14