LCOV - code coverage report
Current view: top level - route - route.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 26 26 100.0 %
Date: 2026-11-30 02:00:48 Functions: 6 7 85.7 %
Legend: Lines: hit not hit

          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             : #include "route/route.h"
       7             : 
       8             : #include "base/time_util.h"
       9             : 
      10     4327490 : Route::Route() {
      11     4327377 : }
      12             : 
      13     4326815 : Route::~Route() {
      14     4326815 : }
      15             : 
      16             : // Selected path
      17     8834491 : const Path *Route::front() const {
      18     8834491 :     PathList::const_iterator it = path_.begin();
      19    17666997 :     if (it == path_.end())
      20     2347136 :         return NULL;
      21     6486117 :     return it.operator->();
      22             : }
      23             : 
      24             : // Insert a path
      25     1045290 : void Route::insert(const Path *ipath) {
      26     1045290 :     Path *path = const_cast<Path *> (ipath);
      27             : 
      28     1045290 :     path->set_time_stamp_usecs(UTCTimestampUsec());
      29     1045320 :     path_.push_back(*path);
      30     1045296 : }
      31             : 
      32             : // Remove a path
      33     1044701 : void Route::remove(const Path *ipath) {
      34     1044701 :     Path *path = const_cast<Path *> (ipath);
      35             : 
      36     1044701 :     path->set_time_stamp_usecs(UTCTimestampUsec());
      37     1045122 :     PathList::const_iterator eraseIt = path_.iterator_to(*path);
      38     2089844 :     path_.erase(eraseIt);
      39     1044973 : }
      40             : 
      41     2317597 : void Route::Sort(Compare compare, const Path *prev_front) {
      42     2317597 :     path_.sort(compare);
      43             : 
      44     2317509 :     set_last_update_at_to_now();
      45             :     // If the best path changes, update route's time stamp.
      46     2317515 :     if (prev_front != front()) {
      47     1983837 :         set_last_change_at_to_now();
      48             :     }
      49     2317307 : }

Generated by: LCOV version 1.14