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

Generated by: LCOV version 1.14