LCOV - code coverage report
Current view: top level - ifmap - ifmap_util.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 33 35 94.3 %
Date: 2026-11-09 02:10:49 Functions: 6 6 100.0 %
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 "ifmap/ifmap_util.h"
       7             : 
       8             : #include <boost/foreach.hpp>
       9             : #include <boost/tuple/tuple.hpp>
      10             : #include "ifmap/ifmap_link.h"
      11             : #include "ifmap/ifmap_log.h"
      12             : #include "ifmap/ifmap_log_types.h"
      13             : #include "ifmap/ifmap_node.h"
      14             : #include "ifmap/ifmap_table.h"
      15             : 
      16             : using namespace std;
      17             : 
      18          22 : bool IFMapTypenameFilter::VertexFilter(const DBGraphVertex *vertex) const {
      19          22 :     const IFMapNode *node = static_cast<const IFMapNode *>(vertex);
      20          22 :     if (exclude_vertex.find(node->table()->Typename()) != exclude_vertex.end()) {
      21           4 :         return false;
      22             :     } else {
      23          18 :         return true;
      24             :     }
      25             : }
      26             : 
      27          36 : bool IFMapTypenameFilter::EdgeFilter(const DBGraphVertex *source,
      28             :                                      const DBGraphVertex *target,
      29             :                                      const DBGraphEdge *edge) const {
      30          36 :     const IFMapNode *node = static_cast<const IFMapNode *>(source);
      31          36 :     VertexEdgeMap::const_iterator it = exclude_edge.find(node->table()->Typename());
      32          36 :     if (it == exclude_edge.end()) return true;
      33          14 :     const IFMapLink *link = static_cast<const IFMapLink *>(edge);
      34          14 :     if (it->second.find(link->name()) != it->second.end()) {
      35           8 :         return false;
      36             :     } else {
      37           6 :         return true;
      38             :     }
      39             : }
      40             : 
      41          18 : DBGraph::VisitorFilter::AllowedEdgeRetVal IFMapTypenameFilter::AllowedEdges(
      42             :                                            const DBGraphVertex *source) const {
      43          36 :     return std::make_pair(true, DBGraph::VisitorFilter::AllowedEdgeSet());
      44             : }
      45             : 
      46             : // Return true if the node-type is in the white list
      47         866 : bool IFMapTypenameWhiteList::VertexFilter(const DBGraphVertex *vertex) const {
      48         866 :     const IFMapNode *node = static_cast<const IFMapNode *>(vertex);
      49         866 :     if (include_vertex.find(node->table()->Typename()) != include_vertex.end()) {
      50         860 :         return true;
      51             :     } else {
      52           6 :         return false;
      53             :     }
      54             : }
      55             : 
      56         470 : DBGraph::VisitorFilter::AllowedEdgeRetVal IFMapTypenameWhiteList::AllowedEdges(
      57             :                                            const DBGraphVertex *source) const {
      58         470 :     const IFMapNode *node = static_cast<const IFMapNode *>(source);
      59         470 :     VertexEdgeMap::const_iterator it = include_vertex.find(node->table()->Typename());
      60         470 :     assert(it != include_vertex.end());
      61         940 :     return std::make_pair(false, it->second);
      62             : }
      63             : 
      64         392 : bool IFMapTypenameWhiteList::EdgeFilter(const DBGraphVertex *source,
      65             :                                         const DBGraphVertex *target,
      66             :                                         const DBGraphEdge *edge) const {
      67         392 :     const IFMapNode *node = static_cast<const IFMapNode *>(source);
      68         392 :     VertexEdgeMap::const_iterator it = include_vertex.find(node->table()->Typename());
      69         392 :     if (it == include_vertex.end()) {
      70           0 :         IFMAP_WARN(IFMapIdentifierNotFound, "Cant find vertex",
      71             :                    node->table()->Typename());
      72           0 :         return false;
      73             :     }
      74         392 :     const IFMapLink *link = static_cast<const IFMapLink *>(edge);
      75         392 :     if (it->second.find(link->name()) != it->second.end()) {
      76         306 :         return true;
      77             :     } else {
      78          86 :         return false;
      79             :     }
      80             : }

Generated by: LCOV version 1.14