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-23 02:04:52 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     4314846 : Route::Route() {
      11     4314682 : }
      12             : 
      13     4314288 : Route::~Route() {
      14     4314288 : }
      15             : 
      16             : // Selected path
      17     8822022 : const Path *Route::front() const {
      18     8822022 :     PathList::const_iterator it = path_.begin();
      19    17642057 :     if (it == path_.end())
      20     2347179 :         return NULL;
      21     6473512 :     return it.operator->();
      22             : }
      23             : 
      24             : // Insert a path
      25     1045375 : void Route::insert(const Path *ipath) {
      26     1045375 :     Path *path = const_cast<Path *> (ipath);
      27             : 
      28     1045375 :     path->set_time_stamp_usecs(UTCTimestampUsec());
      29     1045396 :     path_.push_back(*path);
      30     1045368 : }
      31             : 
      32             : // Remove a path
      33     1044776 : void Route::remove(const Path *ipath) {
      34     1044776 :     Path *path = const_cast<Path *> (ipath);
      35             : 
      36     1044776 :     path->set_time_stamp_usecs(UTCTimestampUsec());
      37     1045212 :     PathList::const_iterator eraseIt = path_.iterator_to(*path);
      38     2090070 :     path_.erase(eraseIt);
      39     1045087 : }
      40             : 
      41     2317112 : void Route::Sort(Compare compare, const Path *prev_front) {
      42     2317112 :     path_.sort(compare);
      43             : 
      44     2317034 :     set_last_update_at_to_now();
      45             :     // If the best path changes, update route's time stamp.
      46     2317035 :     if (prev_front != front()) {
      47     1984103 :         set_last_change_at_to_now();
      48             :     }
      49     2316814 : }

Generated by: LCOV version 1.14