Nepomuk
The Nepomuk Resource Generator
Overview | Using | Examples | Desktop Ontologies | Resource GeneratorThe 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:
- The ontology file to be parsed
- The target directory where to put the new files
- A variable in which the list of generated headers will be stored
- A variable in which the list of generated sources will be stored
- A variable in which the list of includes will be stored (mostly unused)
- 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.
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