DetectorGraph  2.0
graphanalyzer.hpp
Go to the documentation of this file.
1 // Copyright 2017 Nest Labs, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef DETECTORGRAPH_INCLUDE_DETECTORGRAPHANALYZER_HPP_
16 #define DETECTORGRAPH_INCLUDE_DETECTORGRAPHANALYZER_HPP_
17 
18 
19 #include "graph.hpp"
20 
21 #include <string>
22 
23 namespace DetectorGraph
24 {
25 
26 using namespace std;
27 
28 /**
29  * @brief Class that provides debugging/diagnostics to a DetectorGraph detector graph
30  */
32 {
33 public:
34  GraphAnalyzer(const Graph& aGraph);
35 
36  /**
37  * @brief Sets a filter to produce readable names from mangle C++ ones.
38  *
39  * If not set, NodeNameUtils::GetMinimalName will be used.
40  */
41  void SetStringFilter(std::string (*aStringFilter)(const std::string&));
42 
43  /**
44  * @brief Sets a filter to insert \n at specific points.
45  *
46  * If not set NodeNameUtils::WrapOnCommonEndings
47  */
48  void SetLabelWordWrapper(std::string (*aStringFilter)(const std::string&));
49 
50  /**
51  * @brief Print to aOutFilePath a graphviz visualization of the graph
52  */
53  void GenerateDotFile(const std::string& aOutFilePath) const;
54 
55  /**
56  * @brief Prints to stdout the names of all vertices in the current order
57  */
58  void PrintVertexes() const;
59 
60  /**
61  * @brief Prints whether two detectors post to the same public Topic
62  */
63  bool HasPublicConflict() const;
64 
65 private:
66  std::string GetLegend() const;
67  std::string GenerateNodeName(const char* aCompilerName) const;
68  std::string GenerateNodeLabel(const std::string& aNodeName, int aEvaluationIndex) const;
69 
70 private:
71  const Graph& mGraph;
72  std::string (*mStringFilter)(const std::string&);
73  std::string (*mLabelWordWrapper)(const std::string&);
74 };
75 
76 }
77 
78 #endif // DETECTORGRAPH_INCLUDE_DETECTORGRAPHANALYZER_HPP_
Implements a graph of Topics & Detectors with Input/Output APIs.
Definition: graph.hpp:127
Class that provides debugging/diagnostics to a DetectorGraph detector graph.