OSVR-Core
DOTGraphOutput.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_DOTGraphOutput_h_GUID_3A3C0484_26CE_4E9F_BE40_93CE7454D34B
26 #define INCLUDED_DOTGraphOutput_h_GUID_3A3C0484_26CE_4E9F_BE40_93CE7454D34B
27 
28 // Internal Includes
29 #include "GraphOutputInterface.h"
30 
31 // Library/third-party includes
32 // - none
33 
34 // Standard includes
35 #include <unordered_map>
36 #include <unordered_set>
37 #include <vector>
38 #include <stdint.h>
39 
40 class DOTGraphOutput;
41 class DOTNode : public NodeInterface {
42  public:
43  DOTNode(std::string const &id);
44 
45  virtual std::string const &getID() const { return m_id; }
46 
47  private:
48  std::string const m_id;
49 };
51  public:
52  DOTGraphOutput(std::ostream &stream);
53  virtual ~DOTGraphOutput();
54 
55  virtual NodeInterface &addNode(std::string const &label,
56  std::string const &fullPath,
57  std::string const &type);
58  virtual NodeInterface &getNode(std::string const &fullPath);
59  virtual void addEdge(NodeInterface &tail, NodeInterface &head,
60  std::string const &type,
61  std::string const &data = std::string());
62  void addEdge(DOTNode &tail, DOTNode &head,
63  std::string const &attributes = std::string());
64  virtual void enableTreeOrganization();
65 
66  private:
67  void m_outputNode(std::string const &label, std::string const &id,
68  std::string const &type);
69  void m_outputLineWithId(std::string const &id, std::string const &line);
70  DOTNode &m_addNode(std::string const &fullPath);
71  DOTNode &m_getNode(std::string const &fullPath);
72  DOTNode &m_getNode(NodeInterface const &node);
73  std::string m_getNextID();
74  uint32_t m_count;
75  std::unordered_set<std::string> m_referencedIds;
76  std::vector<std::pair<std::string, std::string> > m_idAndOutput;
77  std::ostream &m_os;
79  std::unordered_map<std::string, osvr::unique_ptr<DOTNode> > m_nodes;
81  std::unordered_map<std::string, std::string> m_nodePathsByID;
82  bool m_treeShape;
83 };
84 
85 #endif // INCLUDED_DOTGraphOutput_h_GUID_3A3C0484_26CE_4E9F_BE40_93CE7454D34B
typename detail::split_list_< List... >::head head
Get the first element of a list.
Definition: SplitList.h:54
typename detail::split_list_< List... >::tail tail
Get the list without its first element.
Definition: SplitList.h:58
Definition: DOTGraphOutput.h:50
Definition: DOTGraphOutput.h:41
Definition: GraphOutputInterface.h:45
Definition: GraphOutputInterface.h:38