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

soprano

Writing Soprano Plugins

Soprano has five kinds of plugins: Soprano::Backend, Soprano::Parser, Soprano::Serializer, Soprano::Query::Parser, and Soprano::Query::Serializer.

Creating a new plugin for Soprano is pretty easy. Imagine, for example, we want to write a new Backend plugin. We simply create a class that inherits from QObject and the Soprano::Backend interface and use the Q_INTERFACES macro to tell Qt's meta-object system about the new plugin. We then export the plugin via the Q_EXPORT_PLUGIN2 macro in the source file.

An example would look as follows:

 class MyBackend : public QObject, public Soprano::Backend
 {
    Q_OBJECT
    Q_INTERFACES(Soprano::Backend)

 public:
    StorageModel* createModel( const QStringList& options = QStringList() ) const;
    bool deleteModelData( const BackendSettings& settings ) const;
    BackendFeatures supportedFeatures() const;
 };

In the implementation file export the plugin so it can be picked up by the plugin loading framework:

 Q_EXPORT_PLUGIN2(soprano_mybackend, MyBackend)

The plugin then needs to be linked as a library and installed into the lib/soprano target folder.

Finally we need to create a desktop file describing the plugin. The minimal desktop file looks as follows (for details see Soprano Plugin Desktop Files):

 [Desktop Entry]
 Encoding=UTF-8
 X-Soprano-Library=libsoprano_mybackend
 X-Soprano-Version=2.1
 Type=Service
 ServiceTypes=Soprano/Backend
 Name=MyBackend
 Comment=My very cool and fast Soprano backend

The desktop file should be installed into share/soprano/plugins so the Soprano::PluginManager will find it.

All plugin interfaces inherit from Soprano::Error::ErrorCache for error handling and subclasses should use Soprano::Error::ErrorCache::clearError() and Soprano::Error::ErrorCache::setError() to report the status.

soprano

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

API Reference

Skip menu "API Reference"
  •   server
  • Decibel
  • eigen
  • eigen2
  •   doc
  • kdewin32
  • Phonon
  •     Backend
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for API Reference by doxygen 1.5.4
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