• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

Syndication Library

Syndication::Mapper

Syndication::Mapper< T > Class Template Reference

A mapper maps an SpecificDocument to something else. More...

#include <mapper.h>

List of all members.


Public Member Functions

virtual boost::shared_ptr< T > map (SpecificDocumentPtr doc) const =0
virtual ~Mapper ()

Detailed Description

template<class T>
class Syndication::Mapper< T >

A mapper maps an SpecificDocument to something else.

The type of this "something else" is specified by the template parameter T. In the default implementation it is used with the Feed interface, but its not limited to that. T can be an arbitrary class.

There are three (advanced and hopefully rare) use cases that require you to implement your own mapper. For more information on the possible uses, see TODO: link docs.

1) Add your own feed parser. In case you need support for another feed format (Okay! News, CDF, completely backward-incompatible Atom 5.0, you name it), you can implement AbstractParser and SpecificDocument for it and provide a Mapper<Feed>

*

 class OkayNewsMapper : public Mapper<Feed>
 {
     public:

     virtual FeedPtr map(SpecificDocumentPtr doc) const { ... }
 };

 parserCollection()->registerParser(new OkayNews::Parser, new OkayNewsMapper);

2) Implement your own mapper for the Feed abstraction, for an existing parser. E.g. if you think Syndication does map Atom all wrong, you can implement your own Atom mapper and use that instead of the default one.

 class MyAtomMapper : public Mapper<Feed>
 {
     public:

     virtual FeedPtr map(SpecificDocumentPtr doc) const { ... }
 };

 parserCollection()->changeMapper("atom", new MyAtomMapper);

3) Use your own abstraction. In case the Feed interface does not fit your needs, you can use your own interface, let's say "MyFeed". Be aware you have to implement custom mappings for all feed formats then:

 class MyFeed
 {
     public:

     QString title() const; // my special title
     QList<Article> articles() const; // I name it articles
 };

 class MyAtomMapper : public Mapper<MyFeed> { ... };
 class MyRDFMapper : public Mapper<MyFeed> { ... };
 class MyRSS2Mapper : public Mapper<MyFeed> { ... };

 ParserCollection<MyFeed>* coll = new ParserCollection<MyFeed>;
 coll->registerParser(new Atom::Parser, new MyAtomMapper);
 coll->registerParser(new RDF::Parser, new MyRDFMapper);
   coll->registerParser(new RSS2::Parser, new MyRSS2Mapper);

Author:
Frank Osterfeld

Definition at line 110 of file mapper.h.


Constructor & Destructor Documentation

template<class T>
virtual Syndication::Mapper< T >::~Mapper (  )  [inline, virtual]

virtual destructor

Definition at line 117 of file mapper.h.


Member Function Documentation

template<class T>
virtual boost::shared_ptr<T> Syndication::Mapper< T >::map ( SpecificDocumentPtr  doc  )  const [pure virtual]

maps a format-specific document to abstraction of type T.

Note:
implementations may assume doc to have the type whose mapping they implement and may just statically cast to the subclass without further checking. If you register your own mapper, it's your responsibility to register the mapper only for the format it actually handles.
Parameters:
doc the document to map.
Returns:
a newly created object implementing the abstraction T.


The documentation for this class was generated from the following file:
  • mapper.h

Syndication Library

Skip menu "Syndication Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.8
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal