Projects/Nepomuk/Resources

    From KDE TechBase
    Revision as of 08:53, 23 August 2012 by Vishesh (talk | contribs)

    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();