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

Nepomuk

The Nepomuk Resource Generator

Overview | Using | Examples | Desktop Ontologies | Resource Generator

The power of Nepomuk lies in the generated classes which allows the application developer to set and retrieve metadata according to standards without knowing any specific RDF URIs or names of properties. The idea is that the resource generator (which is installed along with the Nepomuk libraries) creates Resource subclasses that provide wrapper methods for Resource::getProperty and Resource::setProperty from ontology descriptions.

Syntax

The resource generator executable is called nepomuk-rcgen and has the following syntax:

nepomuk-rcgen --writeall [--templates <tmpl1> [<tmpl2> [<tmpl3> ...]]] --target <sourcefolder> --ontologies <ontologyfile> [<ontologyfile> [<ontologyfile> ...]]

This writes all header and source files that have been generated from the ontology in <ontologyfile> to the destination folder <sourcefolder>. Optionally templates can be specified (see Templates for details on templates).

nepomuk-rcgen --listsources [--prefix <listprefix>] --ontologies <ontologyfile> [<ontologyfile> [<ontologyfile> ...]]

This command simply lists all source files that would be generated from the ontology in <ontologyfile> on stdout. It can be used to create build lists.

nepomuk-rcgen --listheaders [--prefix <listprefix>] --ontologies <ontologyfile> [<ontologyfile> [<ontologyfile> ...]]

This command simply lists all header files that would be generated from the ontology in <ontologyfile> on stdout. It can be used to create installation lists.

nepomuk-rcgen --listincludes --ontologies <ontologyfile> [<ontologyfile> [<ontologyfile> ...]]

This will list all headers that would be generated from <ontologyfile> as include statement on stdout. This is a rarely used command that can help to create a header that automatically includes all classes from this ontology.

Usage through CMake

The simplest way to use the resource generator is through CMake. Nepomuk provides a macro to automatically create a list of source and header files from an ontology file and use them to create arbitrary targets (either link them into an installable library or directly link them into the using application).

To use the Nepomuk cmake magic one has to include the NepomukMacros:

include(NepomukMacros)

This will provide a macro called NEPOMUK_GENERATE_FROM_ONTOLOGY with the following parameters:

  1. The ontology file to be parsed
  2. The target directory where to put the new files
  3. A variable in which the list of generated headers will be stored
  4. A variable in which the list of generated sources will be stored
  5. A variable in which the list of includes will be stored (mostly unused)
  6. An optional list of template files

HELP: This macro needs improvement to make parameters optional!

Example

project(metadata_test)

include(NepomukMacros)

NEPOMUK_GENERATE_FROM_ONTOLOGY(
  myontology.nrl
  ${metadata_test_BINARY_DIR}
  TEST_HEADERS
  TEST_SOURCES
  TEST_INCLUDES
)

kde4_add_library(metadata_test SHARED ${TEST_SOURCES})
target_link_libraries(metadata_test
  kmetadata
)

install(TARGETS metadata_test DESTINATION ${LIB_INSTALL_DIR})
install(FILES ${TEST_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/kmetadata)

Templates

Warning:
Template usage is discouraged. Their main purpose is to support the creation of the basic properties of the Resource class.
An rcgen template has to provide the full skeleton for a generated class including the proper namespace, the constructor, and the destructor. They will be assigned to the specific classes according to their filename: The part before the first dot needs to match the class name in lower case. If the class name if followed by ".h" the template is assigned to the header, if it is followed by ".cpp", the template is assigned to the source. The following variables will be replaced:

Header template

NEPOMUK_OTHERCLASSES

Will be replaced by the declarations of the classes used in the header file.

NEPOMUK_METHODS

Will be replaced by the declarations of the getter and setter methods that are generated for the class.

Source template

NEPOMUK_INCLUDES

Will be replaced by all the necessary includes for the types used in the class.

NEPOMUK_METHODS

Will be replaced with the definitions of the getter and setter methods that are generated for the class.

All

The following variables are also replaced:

NEPOMUK_RESOURCENAME
NEPOMUK_RESOURCENAMELOWER
NEPOMUK_RESOURCETYPEURI
NEPOMUK_PARENTRESOURCE
NEPOMUK_PARENTRESOURCELOWER
NEPOMUK_RESOURCECOMMENT

Nepomuk

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs 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