graphhandler.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * $Id$
4  *
5  *
6  * Copyright (C) 1997-2015 by Dimitri van Heesch.
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation under the terms of the GNU General Public License is hereby
10  * granted. No representations are made about the suitability of this software
11  * for any purpose. It is provided "as is" without express or implied warranty.
12  * See the GNU General Public License for more details.
13  *
14  */
15 
16 #ifndef _GRAPHHANDLER_H
17 #define _GRAPHHANDLER_H
18 
19 #include "stringimpl.h"
20 #include "doxmlintf.h"
21 #include "basehandler.h"
22 #include "baseiterator.h"
23 
24 class NodeHandler;
25 class ChildNodeHandler;
26 class EdgeLabelHandler;
27 
28 class GraphHandler : public IGraph, public BaseHandler<GraphHandler>
29 {
30  friend class NodeIterator;
31  public:
32  GraphHandler(IBaseHandler *parent,const char *endTag);
33  virtual ~GraphHandler();
34 
35  void startGraph(const QXmlAttributes &attrib);
36  void endGraph();
37  void startNode(const QXmlAttributes &attrib);
38  NodeHandler *getNodeById(const QString &id) const;
39 
40  // IGraph
41  virtual INodeIterator *nodes() const;
42 
43  private:
46  QDict<NodeHandler> *m_nodeDict;
47 };
48 
49 //----------------------------------------------------------------------
50 
51 class NodeHandler : public INode, public BaseHandler<NodeHandler>
52 {
53  friend class ChildNodeIterator;
54  public:
56  virtual ~NodeHandler();
57 
58  void startNode(const QXmlAttributes &attrib);
59  void endNode();
60  void startLabel(const QXmlAttributes &attrib);
61  void endLabel();
62  void startLink(const QXmlAttributes &attrib);
63  void endLink();
64  void startChildNode(const QXmlAttributes &attrib);
65 
66  // INode
67  virtual const IString *id() const { return &m_id; }
68  virtual const IString *label() const { return &m_label; }
69  virtual const IString *linkId() const { return &m_link; }
70  virtual IChildNodeIterator *children() const;
71 
72  private:
79 };
80 
81 class NodeIterator : public BaseIterator<INodeIterator,INode,NodeHandler>
82 {
83  public:
86 };
87 
88 //----------------------------------------------------------------------
89 
90 class ChildNodeHandler : public IChildNode, public BaseHandler<ChildNodeHandler>
91 {
92  friend class EdgeLabelIterator;
93  public:
95  virtual ~ChildNodeHandler();
96 
97  void startChildNode(const QXmlAttributes &attrib);
98  void endChildNode();
99  void startEdgeLabel(const QXmlAttributes &attrib);
100 
101  // IChildNode
102  virtual INode *node() const;
103  virtual NodeRelation relation() const { return m_relation; }
104  virtual const IString * relationString() const { return &m_relationString; }
105  virtual IEdgeLabelIterator *edgeLabels() const;
106 
107  private:
114 };
115 
116 class ChildNodeIterator : public BaseIterator<IChildNodeIterator,IChildNode,ChildNodeHandler>
117 {
118  public:
121 };
122 
123 //----------------------------------------------------------------------
124 
125 class EdgeLabelHandler : public IEdgeLabel, public BaseHandler<EdgeLabelHandler>
126 {
127  friend class EdgeLabelIterator;
128  public:
130  virtual ~EdgeLabelHandler();
131 
132  void startEdgeLabel(const QXmlAttributes &attrib);
133  void endEdgeLabel();
134 
135  // IEdgeLabel
136  virtual const IString *label() const { return &m_label; }
137 
138  private:
141 };
142 
143 class EdgeLabelIterator : public BaseIterator<IEdgeLabelIterator,IEdgeLabel,EdgeLabelHandler>
144 {
145  public:
148 };
149 
150 void graphhandler_init();
151 void graphhandler_exit();
152 
153 #endif
154 
virtual const IString * label() const
Definition: graphhandler.h:68
EdgeLabelIterator(const ChildNodeHandler &handler)
Definition: graphhandler.h:146
Read only interface to a string.
Definition: doxmlintf.h:42
NodeHandler * getNodeById(const QString &id) const
virtual const IString * id() const
Definition: graphhandler.h:67
GraphHandler(IBaseHandler *parent, const char *endTag)
IBaseHandler * m_parent
Definition: graphhandler.h:139
ChildNodeIterator(const NodeHandler &handler)
Definition: graphhandler.h:119
GraphHandler * m_graph
Definition: graphhandler.h:113
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QList< EdgeLabelHandler > m_edgeLabels
Definition: graphhandler.h:112
StringImpl m_label
Definition: graphhandler.h:75
void startGraph(const QXmlAttributes &attrib)
void startNode(const QXmlAttributes &attrib)
GraphHandler * m_graph
Definition: graphhandler.h:78
QList< ChildNodeHandler > m_children
Definition: graphhandler.h:77
StringImpl m_link
Definition: graphhandler.h:76
virtual const IString * relationString() const
Definition: graphhandler.h:104
virtual const IString * linkId() const
Definition: graphhandler.h:69
NodeRelation m_relation
Definition: graphhandler.h:110
QList< NodeHandler > m_nodes
Definition: graphhandler.h:45
void graphhandler_exit()
virtual ~GraphHandler()
virtual NodeRelation relation() const
Definition: graphhandler.h:103
IBaseHandler * m_parent
Definition: graphhandler.h:73
NodeIterator(const GraphHandler &handler)
Definition: graphhandler.h:84
QDict< NodeHandler > * m_nodeDict
Definition: graphhandler.h:46
The QXmlAttributes class provides XML attributes.
Definition: qxml.h:128
IBaseHandler * m_parent
Definition: graphhandler.h:108
static msg_handler handler
Definition: qglobal.cpp:234
StringImpl m_label
Definition: graphhandler.h:140
StringImpl m_id
Definition: graphhandler.h:74
virtual INodeIterator * nodes() const
IBaseHandler * m_parent
Definition: graphhandler.h:44
virtual const IString * label() const
Definition: graphhandler.h:136
def parent(G, child, parent_type)
Definition: graph.py:67
void graphhandler_init()
StringImpl m_relationString
Definition: graphhandler.h:111
The interface to the object model provided by the XML parser library.