1/*
2 * This file is part of the syndication library
3 *
4 * Copyright (C) 2005 Frank Osterfeld <osterfeld@kde.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You must have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22#ifndef SYNDICATION_DOCUMENTVISITOR_H
23#define SYNDICATION_DOCUMENTVISITOR_H
24
25#include "ksyndication_export.h"
26
27namespace Syndication {
28
29class SpecificDocument;
30
31namespace Atom
32{
33 class EntryDocument;
34 class FeedDocument;
35}
36
37namespace RDF
38{
39 class Document;
40}
41
42namespace RSS2
43{
44 class Document;
45}
46
47/**
48 * Visitor interface, following the Visitor design pattern. Use this if you
49 * want to process documents and the way how to handle the document depends
50 * on it's concrete type (e.g. RSS2::Document, RDF::Document...).
51 *
52 * TODO: insert code example
53 *
54 * @author Frank Osterfeld
55 */
56class SYNDICATION_EXPORT DocumentVisitor //krazy:exclude=dpointer
57{
58 public:
59
60 /**
61 * destructor
62 */
63 virtual ~DocumentVisitor();
64
65 /**
66 * call this method to handle a document. Depending on the concrete type
67 * of the document, a specialized visit method is called.
68 *
69 * @param document the document to process
70 * @return whether this visitor handles the type of the document.
71 */
72 virtual bool visit(SpecificDocument* document);
73
74 /**
75 * reimplement this method to handle RSS2-like (RSS 0.9x, 2.0) documents.
76 *
77 * @param document the RSS2 document to visit
78 * @return whether the visitor handled the document.
79 * Reimplementations of this method must return @c true.
80 */
81 virtual bool visitRSS2Document(Syndication::RSS2::Document* document);
82
83 /**
84 * reimplement this method to handle RDF (i.e. RSS 1.0) documents.
85 *
86 * @param document the RDF document to visit
87 * @return whether the visitor handled the document.
88 * Reimplementations of this method must return @c true.
89 */
90 virtual bool visitRDFDocument(Syndication::RDF::Document* document);
91
92 /**
93 * reimplement this method to handle Atom feed documents (most Atom
94 * feeds are of this type).
95 *
96 * @param document the atom feed document to visit
97 * @return whether the visitor handled the document.
98 * Reimplementations of this method must return @c true.
99 */
100 virtual bool visitAtomFeedDocument(Syndication::Atom::FeedDocument* document);
101
102 /**
103 * reimplement this method to handle Atom entry documents.
104 *
105 * @param document the atom entry document to visit
106 * @return whether the visitor handled the document.
107 * Reimplementations of this method must return @c true.
108 */
109 virtual bool visitAtomEntryDocument(Syndication::Atom::EntryDocument* document);
110};
111
112} // namespace Syndication
113
114#endif // SYNDICATION_DOCUMENTVISITOR_H
115