Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

GraphVizVisitor.h

00001 #ifndef _STR_GraphVizVisitor_H_  // -*-mode: c++; c-file-style: "gmtellemtel";-*-
00002 
00003 /*
00004  * Copyright 2000-2002 by Eric M. Hopper <hopper@omnifarious.org>
00005  * 
00006  *     This program is free software; you can redistribute it and/or modify it
00007  *     under the terms of the GNU Lesser General Public License as published
00008  *     by the Free Software Foundation; either version 2 of the License, or
00009  *     (at your option) any later version.
00010  * 
00011  *     This program is distributed in the hope that it will be useful, but
00012  *     WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *     Lesser General Public License for more details.
00015  * 
00016  *     You should have received a copy of the GNU Lesser General Public
00017  *     License along with this program; if not, write to the Free Software
00018  *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #ifdef __GNUG__
00022 #  pragma interface
00023 #endif
00024 
00025 /* $Header: /home/hopper/src/cvs/C++/StrMod/StrMod/GraphVizVisitor.h,v 1.8 2002/08/29 00:58:04 hopper Exp $ */
00026 
00027 // For a log, see ../ChangeLog
00028 
00029 #include <StrMod/UseTrackingVisitor.h>
00030 #include <set>
00031 #include <utility>
00032 
00033 #define _STR_GraphVizVisitor_H_
00034 
00035 namespace strmod {
00036 namespace strmod {
00037 
00038 class BufferChunk;
00039 
00040 /** \class GraphVizVisitor GraphVizVisitor.h StrMod/GraphVizVisitor.h
00041  * Generates output suitable for AT&T's Open Source GraphViz program, found at
00042  * http://www.research.att.com/sw/tools/graphviz/
00043  */
00044 class GraphVizVisitor : public UseTrackingVisitor
00045 {
00046  public:
00047    static const STR_ClassIdent identifier;
00048 
00049    //! Constructor, doesn't do much.
00050    GraphVizVisitor() : out_(0)      { }
00051    //! Destructor, also doesn't do much.
00052    virtual ~GraphVizVisitor()       { }
00053 
00054    virtual int AreYouA(const lcore::ClassIdent &cid) const {
00055       return((identifier == cid) || UseTrackingVisitor::AreYouA(cid));
00056    }
00057 
00058    /**
00059     * Visits the chunk DAG printing out a GraphViz parsable graph description,
00060     * returning a StrChunk containing the data for the chunk DAG.
00061     */
00062    const StrChunkPtr visit(const StrChunkPtr &root, std::ostream &out);
00063 
00064  protected:
00065    virtual const lcore::ClassIdent *i_GetIdent() const  { return &identifier; }
00066 
00067    virtual void use_visitStrChunk(const StrChunkPtr &chunk,
00068                                   const LinearExtent &used)
00069       throw(halt_visitation);
00070 
00071    virtual void use_visitDataBlock(const void *start, size_t len,
00072                                    const void *realstart, size_t reallen)
00073       throw(halt_visitation);
00074 
00075    void printData(const void *data, size_t len);
00076 
00077  private:
00078    typedef std::pair<const void *, const void *> edge_t;
00079    typedef std::set<edge_t> edgeset_t;
00080    std::ostream *out_;
00081    BufferChunk *data_;
00082    size_t rootpos_;
00083    edgeset_t edges_;
00084 };
00085 
00086 };  // namespace strmod
00087 };  // namespace strmod
00088 
00089 #endif

Generated on Wed Jan 29 00:32:43 2003 for libNet by doxygen1.3-rc1