Projects/Nepomuk/Resources: Difference between revisions

From KDE TechBase
(Added information about the Nepomuk Resource Generator)
 
No edit summary
Line 1: Line 1:
The Nepomuk Resource class is undoubtedly the most user visible and used class. It serves as a very convenient abstraction over the statements.
The Nepomuk Resource class is undoubtedly the most user visible and used class. It serves as a very convenient abstraction over the statements.


== Nepomuk Resource Generator =
= Nepomuk Resource Generator =


While it is fairly convenient to use the <code>setProperty</code> and <code>getProperty</code> methods. It requires you to explicitly define the property which you need modify. This can get quite cumbersome and destroys readability of the code.
While it is fairly convenient to use the <code>setProperty</code> and <code>getProperty</code> methods. It requires you to explicitly define the property which you need modify. This can get quite cumbersome and destroys readability of the code.

Revision as of 08:53, 23 August 2012

The Nepomuk Resource class is undoubtedly the most user visible and used class. It serves as a very convenient abstraction over the statements.

Nepomuk Resource Generator

While it is fairly convenient to use the setProperty and getProperty methods. It requires you to explicitly define the property which you need modify. This can get quite cumbersome and destroys readability of the code.

In order to improve this situation we have provided a resource generator, which generates custom Resource classes from the ontologies. It relies on a CMake macro to accomplish that.

nepomuk2_add_ontology_classes (SRCS
    ONTOLOGIES
    ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nie.trig
    ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nco.trig
    ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/pimo/pimo.trig
)


This will generate a C++ class for each type defined in the mentioned ontologies.

#include "personcontact.h"

Nepomuk2::PersonContact spiderman;
spiderman.setFullName( QLatin1String("Peter Parker") );
QString name = spiderman.fullname();