File indexing completed on 2024-04-14 03:58:29

0001 /*
0002     This file is part of the syndication library
0003     SPDX-FileCopyrightText: 2005 Frank Osterfeld <osterfeld@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef SYNDICATION_DOCUMENTVISITOR_H
0009 #define SYNDICATION_DOCUMENTVISITOR_H
0010 
0011 #include "syndication_export.h"
0012 
0013 namespace Syndication
0014 {
0015 class SpecificDocument;
0016 
0017 namespace Atom
0018 {
0019 class EntryDocument;
0020 class FeedDocument;
0021 }
0022 
0023 namespace RDF
0024 {
0025 class Document;
0026 }
0027 
0028 namespace RSS2
0029 {
0030 class Document;
0031 }
0032 
0033 /**
0034  * Visitor interface, following the Visitor design pattern. Use this if you
0035  * want to process documents and the way how to handle the document depends
0036  * on it's concrete type (e.g. RSS2::Document, RDF::Document...).
0037  *
0038  * TODO: insert code example
0039  *
0040  * @author Frank Osterfeld
0041  */
0042 class SYNDICATION_EXPORT DocumentVisitor // krazy:exclude=dpointer
0043 {
0044 public:
0045     /**
0046      * destructor
0047      */
0048     virtual ~DocumentVisitor();
0049 
0050     /**
0051      * call this method to handle a document. Depending on the concrete type
0052      * of the document, a specialized visit method is called.
0053      *
0054      * @param document the document to process
0055      * @return whether this visitor handles the type of the document.
0056      */
0057     virtual bool visit(SpecificDocument *document);
0058 
0059     /**
0060      * reimplement this method to handle RSS2-like (RSS 0.9x, 2.0) documents.
0061      *
0062      * @param document the RSS2 document to visit
0063      * @return whether the visitor handled the document.
0064      * Reimplementations of this method must return @c true.
0065      */
0066     virtual bool visitRSS2Document(Syndication::RSS2::Document *document);
0067 
0068     /**
0069      * reimplement this method to handle RDF (i.e. RSS 1.0) documents.
0070      *
0071      * @param document the RDF document to visit
0072      * @return whether the visitor handled the document.
0073      * Reimplementations of this method must return @c true.
0074      */
0075     virtual bool visitRDFDocument(Syndication::RDF::Document *document);
0076 
0077     /**
0078      * reimplement this method to handle Atom feed documents (most Atom
0079      * feeds are of this type).
0080      *
0081      * @param document the atom feed document to visit
0082      * @return whether the visitor handled the document.
0083      * Reimplementations of this method must return @c true.
0084      */
0085     virtual bool visitAtomFeedDocument(Syndication::Atom::FeedDocument *document);
0086 
0087     /**
0088      * reimplement this method to handle Atom entry documents.
0089      *
0090      * @param document the atom entry document to visit
0091      * @return whether the visitor handled the document.
0092      * Reimplementations of this method must return @c true.
0093      */
0094     virtual bool visitAtomEntryDocument(Syndication::Atom::EntryDocument *document);
0095 };
0096 
0097 } // namespace Syndication
0098 
0099 #endif // SYNDICATION_DOCUMENTVISITOR_H