LCOV - code coverage report
Current view: top level - db - db_graph_base.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 10 10 100.0 %
Date: 2026-06-18 01:51:13 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #ifndef ctrlplane_db_graph_base_h
       6             : #define ctrlplane_db_graph_base_h
       7             : 
       8             : #include <boost/graph/graph_traits.hpp>
       9             : #include <boost/graph/adjacency_list.hpp>
      10             : #include <boost/graph/properties.hpp>
      11             : 
      12             : class DBGraphVertex;
      13             : class DBGraphEdge;
      14             : 
      15             : template <class StoredEdge>
      16             : struct order_by_name : public std::binary_function<StoredEdge, StoredEdge, bool>
      17             : {
      18             :   bool operator()(const StoredEdge& e1, const StoredEdge& e2) const;
      19             : };
      20             : 
      21             : struct ordered_set_by_nameS { };
      22             : 
      23             : namespace boost {
      24             :   template <class ValueType>
      25             :   struct container_gen<ordered_set_by_nameS, ValueType> {
      26             :     typedef std::multiset<ValueType, order_by_name<ValueType> > type;
      27             :   };
      28             :   template <>
      29             :   struct parallel_edge_traits<ordered_set_by_nameS> {
      30             :       typedef disallow_parallel_edge_tag type;
      31             :   };
      32             : }
      33             : 
      34             : class DBGraphBase {
      35             : public:
      36        8252 :     DBGraphBase() : graph_walk_num_(0) {
      37        8252 :     }
      38             : 
      39             :     struct VertexProperties {
      40      189140 :         VertexProperties() : entry(NULL) {
      41      189140 :         }
      42             :         DBGraphVertex *entry;
      43             :     };
      44             : 
      45             :     struct EdgeProperties {
      46      163238 :         EdgeProperties(std::string name, DBGraphEdge *e) : name_(name), edge(e) {
      47      163238 :         }
      48      604062 :         const std::string &name() const {
      49      604062 :             return name_;
      50             :         }
      51             :         std::string name_;
      52             :         DBGraphEdge *edge;
      53             :     };
      54             : 
      55             :     typedef boost::adjacency_list<
      56             :         ordered_set_by_nameS, boost::listS, boost::undirectedS,
      57             :         VertexProperties, EdgeProperties> graph_t;
      58             :     typedef boost::graph_traits<graph_t >::vertex_descriptor vertex_descriptor;
      59             :     typedef boost::graph_traits<graph_t >::edge_descriptor edge_descriptor;
      60             :     typedef boost::graph_traits<graph_t >::adjacency_iterator adjacency_iterator;
      61             :     typedef boost::graph_traits<graph_t >::edge_iterator edge_iterator;
      62             :     typedef boost::graph_traits<graph_t >::out_edge_iterator out_edge_iterator;
      63             : 
      64             :     typedef graph_t::StoredEdge StoredEdge;
      65             :     typedef boost::container_gen<graph_t::out_edge_list_selector,
      66             :             StoredEdge>::type OutEdgeListType;
      67             :     typedef OutEdgeListType::iterator OutEdgeIterator;
      68             : 
      69             :     typedef graph_t::EdgeContainer EdgeContainer;
      70             :     typedef EdgeContainer::value_type EdgeType;
      71             : 
      72         129 :     uint64_t get_graph_walk_num() {
      73         129 :         return ++graph_walk_num_;
      74             :     }
      75             : 
      76             : private:
      77             :     uint64_t graph_walk_num_;
      78             : };
      79             : 
      80             : #endif

Generated by: LCOV version 1.14