LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DOTGraphTraits.h

Go to the documentation of this file.
00001 //===-- llvm/Support/DotGraphTraits.h - Customize .dot output ---*- C++ -*-===//
00002 // 
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 // 
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines a template class that can be used to customize dot output
00011 // graphs generated by the GraphWriter.h file.  The default implementation of
00012 // this file will produce a simple, but not very polished graph.  By
00013 // specializing this template, lots of customization opportunities are possible.
00014 //
00015 //===----------------------------------------------------------------------===//
00016 
00017 #ifndef LLVM_SUPPORT_DOTGRAPHTRAITS_H
00018 #define LLVM_SUPPORT_DOTGRAPHTRAITS_H
00019 
00020 #include <string>
00021 
00022 namespace llvm {
00023 
00024 /// DefaultDOTGraphTraits - This class provides the default implementations of
00025 /// all of the DOTGraphTraits methods.  If a specialization does not need to
00026 /// override all methods here it should inherit so that it can get the default
00027 /// implementations.
00028 ///
00029 struct DefaultDOTGraphTraits {
00030   /// getGraphName - Return the label for the graph as a whole.  Printed at the
00031   /// top of the graph.
00032   ///
00033   static std::string getGraphName(const void *Graph) { return ""; }
00034 
00035   /// getGraphProperties - Return any custom properties that should be included
00036   /// in the top level graph structure for dot.
00037   ///
00038   static std::string getGraphProperties(const void *Graph) {
00039     return "";
00040   }
00041 
00042   /// getNodeLabel - Given a node and a pointer to the top level graph, return
00043   /// the label to print in the node.
00044   static std::string getNodeLabel(const void *Node, const void *Graph) {
00045     return "";
00046   }
00047 
00048   /// If you want to specify custom node attributes, this is the place to do so
00049   ///
00050   static std::string getNodeAttributes(const void *Node) { return ""; }
00051 
00052   /// If you want to override the dot attributes printed for a particular edge,
00053   /// override this method.
00054   template<typename EdgeIter>
00055   static std::string getEdgeAttributes(const void *Node, EdgeIter EI) {
00056     return "";
00057   }
00058 
00059   /// getEdgeSourceLabel - If you want to label the edge source itself,
00060   /// implement this method.
00061   template<typename EdgeIter>
00062   static std::string getEdgeSourceLabel(const void *Node, EdgeIter I) {
00063     return "";
00064   }
00065 
00066   /// edgeTargetsEdgeSource - This method returns true if this outgoing edge
00067   /// should actually target another edge source, not a node.  If this method is
00068   /// implemented, getEdgeTarget should be implemented.
00069   template<typename EdgeIter>
00070   static bool edgeTargetsEdgeSource(const void *Node, EdgeIter I) {
00071     return false;
00072   }
00073 
00074   /// getEdgeTarget - If edgeTargetsEdgeSource returns true, this method is
00075   /// called to determine which outgoing edge of Node is the target of this
00076   /// edge.
00077   template<typename EdgeIter>
00078   static EdgeIter getEdgeTarget(const void *Node, EdgeIter I) {
00079     return I;
00080   }
00081 
00082   /// addCustomGraphFeatures - If a graph is made up of more than just
00083   /// straight-forward nodes and edges, this is the place to put all of the
00084   /// custom stuff necessary.  The GraphWriter object, instantiated with your
00085   /// GraphType is passed in as an argument.  You may call arbitrary methods on
00086   /// it to add things to the output graph.
00087   ///
00088   template<typename GraphWriter>
00089   static void addCustomGraphFeatures(const void *Graph, GraphWriter &GW) {}
00090 };
00091 
00092 
00093 /// DOTGraphTraits - Template class that can be specialized to customize how
00094 /// graphs are converted to 'dot' graphs.  When specializing, you may inherit
00095 /// from DefaultDOTGraphTraits if you don't need to override everything.
00096 ///
00097 template <typename Ty>
00098 struct DOTGraphTraits : public DefaultDOTGraphTraits {};
00099 
00100 } // End llvm namespace
00101 
00102 #endif