Soprano
2.8.0
|
Using Soprano in your own project is pretty straight forward. Soprano provides includes for all classes and enumerations. Using a Soprano class like Statement is as simple as including
For an easy start one can simply include the Soprano header which pulls in all classes. The following code shows a simple example of a Soprano application which creates a new Model, adds a Statement, and lists it.
Integrating Soprano into your own build system is rather simple. Soprano provides a set of libraries and one include path. The libraries are:
A PkgConfig description is provided for the core library and can be used as described in the following.
Soprano provides pkg-config integration which allows to build the above example using qmake. The following pro file looks for Soprano includes and libs via pkg-config and builds the application sopranotest.
Using cmake is simple. Find required packages Qt4 and PkgConfig, look for Soprano via PkgConfig and link to both Soprano and QtCore:
Soprano provides the simple onto2vocabularyclass tool which can generate convenience namespaces such as Soprano::Vocabulary::RDF from ontology files. With CMake it is very simple to generate these namespaces on-the-fly instead of packaging the generated files by using the SopranoAddOntology macro provided by Soprano:
Imagine one's code contains an ontology description in rdf+xml format named Foo (Foo Object Ontology) and you want to make its classes and properties accessible in the MyStuff::Foo namespace. One simply includes the cmake macro provided by Soprano:
And then uses it to add the generated files to the sources:
This will add a command to generate files foo.h and foo.cpp at build time and add the latter to the sources foo_SOURCES. The generated namespace will be named Vocabulary::FOO. It is optionally possible to make the namespace public API and export it by adding the VISIBILITY keyword: