1 /*
2     This file is part of the syndication library
3     SPDX-FileCopyrightText: 2005 Frank Osterfeld <osterfeld@kde.org>
4 
5     SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef SYNDICATION_DOCUMENTVISITOR_H
9 #define SYNDICATION_DOCUMENTVISITOR_H
10 
11 #include "syndication_export.h"
12 
13 namespace Syndication
14 {
15 class SpecificDocument;
16 
17 namespace Atom
18 {
19 class EntryDocument;
20 class FeedDocument;
21 }
22 
23 namespace RDF
24 {
25 class Document;
26 }
27 
28 namespace RSS2
29 {
30 class Document;
31 }
32 
33 /**
34  * Visitor interface, following the Visitor design pattern. Use this if you
35  * want to process documents and the way how to handle the document depends
36  * on it's concrete type (e.g. RSS2::Document, RDF::Document...).
37  *
38  * TODO: insert code example
39  *
40  * @author Frank Osterfeld
41  */
42 class SYNDICATION_EXPORT DocumentVisitor // krazy:exclude=dpointer
43 {
44 public:
45     /**
46      * destructor
47      */
48     virtual ~DocumentVisitor();
49 
50     /**
51      * call this method to handle a document. Depending on the concrete type
52      * of the document, a specialized visit method is called.
53      *
54      * @param document the document to process
55      * @return whether this visitor handles the type of the document.
56      */
57     virtual bool visit(SpecificDocument *document);
58 
59     /**
60      * reimplement this method to handle RSS2-like (RSS 0.9x, 2.0) documents.
61      *
62      * @param document the RSS2 document to visit
63      * @return whether the visitor handled the document.
64      * Reimplementations of this method must return @c true.
65      */
66     virtual bool visitRSS2Document(Syndication::RSS2::Document *document);
67 
68     /**
69      * reimplement this method to handle RDF (i.e. RSS 1.0) documents.
70      *
71      * @param document the RDF document to visit
72      * @return whether the visitor handled the document.
73      * Reimplementations of this method must return @c true.
74      */
75     virtual bool visitRDFDocument(Syndication::RDF::Document *document);
76 
77     /**
78      * reimplement this method to handle Atom feed documents (most Atom
79      * feeds are of this type).
80      *
81      * @param document the atom feed document to visit
82      * @return whether the visitor handled the document.
83      * Reimplementations of this method must return @c true.
84      */
85     virtual bool visitAtomFeedDocument(Syndication::Atom::FeedDocument *document);
86 
87     /**
88      * reimplement this method to handle Atom entry documents.
89      *
90      * @param document the atom entry document to visit
91      * @return whether the visitor handled the document.
92      * Reimplementations of this method must return @c true.
93      */
94     virtual bool visitAtomEntryDocument(Syndication::Atom::EntryDocument *document);
95 };
96 
97 } // namespace Syndication
98 
99 #endif // SYNDICATION_DOCUMENTVISITOR_H
100